[














	/*
		PDQ_DateFromString
		
		Returns (true|false)
		
		Munges a string to turn it into a date, if it is at all possible
		
	*/
//	If: !(Lasso_TagExists: 'PDQ_DateFromString');
			define_tag:'PDQ_DateFromString', -Required='Input', -priority='replace';
					// see if it's a valid_date
					if: valid_date(#Input);
							// it appears to be valid the way it is
							local: 'a_input' = date(#input)->Format('%Q %H:%M:%S');
							if: string(#a_input) >> '0000-00-00';
							else: string(#a_input) >> '0000';
									local: 'munged_date' = #a_input;
									#munged_date = date(#munged_date);
									#munged_date = string(#munged_date);
									#munged_date = 
										(String_ReplaceRegExp:
											#munged_date,
											-Find='0000',
											-Replace=((date)->Year(-Long)),
											)
										;
									#a_input = #munged_date;
							/if;
							return(date(#a_input));
					else;
							local: 'a_input' = #input;
							
							local('newstring'=string);
							if(#a_input >> '/');
									iterate(string(#a_input), local('a_char'));
											
											if(#a_char >> '/');
													#newstring += '-';
											else;
													#newstring += #a_char;
											/if;
									/iterate;
							/if;
							
							#newstring->size != 0 ? #a_input = date(#newstring);
							
							
							if: #a_input == 'Now';
									return(date);
							/if;
							
							if: #a_input == 'Today';
									return(PDQ_DateFromSTring(date(date->Format('%Q'))));
							/if;
							
							local: 'some_monthNumbers' = (array);
							loop(12);
									#some_monthNumbers->Insert(loop_count);
							/loop;
							local: 'some_months' = (array);
							iterate: #some_monthNumbers, local('a_num');
									local: 'this_num' = integer(date(#a_num '/15/2010')->Month());
									if: #this_num < 10;
											#this_num = string('0' + #this_num);
									/if;
									#some_months->Insert(date(#a_num '/15/2010')->Month(-Long)=#this_num);
									
									#some_months->Insert(date(#a_num '/15/2010')->Month(-Short)=#this_num);
							/iterate;
							
							
							
							
							local: 'some_dayNumbers' = (array);
							loop(7);
									#some_dayNumbers->Insert(loop_count);
							/loop;
							local: 'daysMap' = (map);
							local: 'some_days' = (array);
							iterate: #some_dayNumbers, local('a_num');
									local: 'this_num' = integer(date('01/' #a_num '/2010')->DayOfWeek());
									#some_days->Insert(date('01/' #a_num '/2010')->DayOfWeek(-Long)=#this_num);
									#daysMap->  Insert((date('01/' #a_num '/2010')->DayOfWeek(-Long)=#this_num));
									
									#some_days->Insert(date('01/' #a_num '/2010')->DayOfWeek(-Short)=#this_num);
									#daysMap->Insert((date('01/' #a_num '/2010')->DayOfWeek(-Short)=#this_num));
							/iterate;
							
							
							iterate: #some_days, local: 'a_day';
									if: #a_input == #a_day;
											local: 'a_DayNum' = #a_day->Second;
											local: 'today_DayNum' =((date)->DayOfWeek());
											local: 'tempdate' = (date);
											#tempdate->Add(-Day=#a_dayNum);
											#a_input = #tempdate;
									/if;
							/iterate;
							
							iterate: #some_days, local: 'a_day';
									if: #a_input == ('next ' #a_day->First);
											local: 'a_DayNum' = #a_day->Second;
											local: 'today_DayNum' =((date)->DayOfWeek());
											local: 'tempdate' = (date);
											#tempdate->Add(-Day=#a_dayNum);
											#a_input = #tempdate;
									/if;
							/iterate;
							
							iterate: #some_days, local: 'a_day';
									if: #a_input ==('last ' #a_day->First);
											local: 'a_DayNum' = #a_day->Second;
											local: 'today_DayNum' =((date)->DayOfWeek());
											local: 'tempdate' = (date);
											#tempdate->Subtract(-Day=#a_dayNum);
											#a_input = #tempdate;
									/if;
							/iterate;
							
							
							
							local: 'munged_date' = #a_Input;
							
							// replace any commas with nothing
							#munged_date = 
								(String_ReplaceRegExp:
									#munged_date,
									-Find='(,+)',
									-Replace='',
									)
								;
							
							// replace any / with -
							
							#munged_date = #munged_date->Split(' ');
							local: 'new_split' = array;
							iterate: #munged_date, local: 'a_member';
									if: (integer(#a_member)) > 0 && (integer(#a_member)) < 3;
											#new_split->Insert(string('0' + string(#a_member)));
									else;
											#new_split->Insert(#a_member);
									/if;
							/iterate;
							#munged_date = #new_split;
							
							#munged_date = #munged_date->Join('/');
							
							
							// replace the month
							iterate: #some_months, local: 'a_month';
									if: #a_input >> #a_month->First;
											#munged_date = 
												(String_ReplaceRegExp:
													#munged_date,
													-Find='(' #a_month->First ')',
													-Replace=#a_month->Second,
													)
												;
											local: 'a_input' = #munged_date;
											
											Loop_Abort;
									/if;
							/iterate;
							
							
							local: 'regex' = '([20|19]+\\d\\d)[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])';
							local: 'regex_delimeter' = '[- /.]';
							local: 'regex_day' = '(0[1-9]|[12][0-9]|3[01])';
							local: 'regex_month' = '(0[1-9]|1[012])';
							local: 'regex_year' = '([20|19]+\\d\\d)';
							local: 'patterns_order' = array('normal','us','uk');

							local: 'patterns' = 

								map(
									'normal'=array('year', 'month', 'day'),
									'us'=array('month', 'day', 'year'),
									'uk'=array('day', 'month', 'year')
									),
								;
								
							local: 'exit' = false;
							local: 'output' = '';
							iterate: #patterns_order, local: 'a_pattern';
									local: 'a_regex' = '';
									local: 'this_pattern' = #a_pattern;
									iterate: #patterns->Find(#this_pattern), local: 'a_subPattern';
											#a_regex += local('regex_' + #a_subPattern);
											if: loop_count < #patterns->size;
													#a_regex += #regex_delimeter;
											/if;
									/iterate;
									if: boolean(String_FindRegexp(#a_input, -Find=#a_regex));
											local: 'output' = String_FindRegexp(#a_input, -Find=#a_regex);
											#output->Remove(1);
											#output = #output->Join('/');
											local: 'this' = #output;
											if: valid_date(#output);
													// this may be our baby
													return(PDQ_DateFromString(date(#output)));
											else;
													if: #this_pattern == 'uk';
															local: 'this' = (date(String_ReplaceRegexp(#output, -Find=(#regex_day #regex_delimeter #regex_month #regex_delimeter #regex_year), -Replace='\\2/\\1/\\3')));
															return(PDQ_DateFromSTring(date(#this)));
													/if;
											/if;
											loop_abort;
									else;
									
											local: 'this' = #munged_date;
											if: valid_date(#this);
													if: string(#this) >> '0000';
															local: 'munged_date' = #this;
															#munged_date = date(#munged_date);
															#munged_date = string(#munged_date);
															#munged_date = 
																(String_ReplaceRegExp:
																	#munged_date,
																	-Find='0000',
																	-Replace=((date)->Year(-Long)),
																	)
																;
															#this = #munged_date;
													/if;
													return(PDQ_DateFromSTring(date(#this)));
											else: valid_date(#this + '/2004');
													return(PDQ_DateFromSTring(date(#this + '/2004')));
											/if;
									/if;
							/iterate;
							
							//return('found something');

							local: 'munged_date' = #this;
							#munged_date = date(#munged_date);
							#munged_date = string(#munged_date);
							#munged_date = 
								(String_ReplaceRegExp:
									#munged_date,
									-Find='0000',
									-Replace=((date)->Year(-Long)),
									)
								;
							
							
							
							// we are going to have to munge it  :(
							
							
						
							
							// normalize whitespace
							#munged_date = 
								(String_ReplaceRegExp:
									#munged_date,
									-Find='(\s+)',
									-Replace=' ',
									)
								;
							
							
							// replace the month
							iterate: #some_months, local: 'a_month';
									#munged_date = 
										(String_ReplaceRegExp:
											#munged_date,
											-Find='(' #a_month ')',
											-Replace=' ',
											)
										;
							/iterate;
							
							
							
							// replace any hyphens with slashes
							#munged_date = 
								(String_ReplaceRegExp:
									#munged_date,
									-Find='(-+)',
									-Replace='/',
									)
								;
							
							if: valid_date(#munged_date);
									return((date(#munged_date))->Format('%Q %H:%M:%S'));
							else;
									return(false);
							/if;
					/if;
					
					
			/define_tag;
//	/If;



	
	/*
		PDQ_Valid_Date
		
		Returns (true|false)
		
		Checks to see whether a supplied value is a valid date, and, if supplied, the required format
		
		
		!!! FORMAT IS NOT IMPLEMENTED AS OF 10/2/04 6:52 PM  !!!
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Date');
			define_tag:'PDQ_Valid_Date', -Required='Input', -Optional='Format';
			
					// NOTE: -Format is not implemented yet
			
					// first we'll see if we have to match a certain format
/* 					if: (params) >> -Format; */
/* 							// yes, we do */
/* 							local:'a_format' = String(#Format); */
/* 							local: 'enforceFormat' = true; */
/* 							 */
/* 							// NOTE -- FORMAT IS NOT IMPLEMENTED YET, HENCE, THE OVERRIDE HERE: */
/* 							local: 'enforceFormat' = false; */
/* 					else; */
/* 							// no, any old format will do */
/* 							local: 'enforceFormat' = false; */
/* 					/if; */
					
					if: valid_date(PDQ_DateFromString(#Input));
							return(true);
					else;
							return(false);
					/if;
					
			/define_tag;
	/If;
	
	
	
	
	
	
	
	
	/*
		PDQ_Valid_MaxLength
		
		Returns (true|false)
		
		Checks to see whether a supplied value is longer than the supplied allowed value
	
		      maxLength: compares length of submitted value to maxLength
		          input: any -- casts to string before compare
		        returns: true | false
	*/
	$PDQ_ValidationKeys->insert('maxLength');
	$PDQ_ValidationTags->insert('maxLength'='PDQ_Valid_MaxLength');
	If: !(Lasso_TagExists: 'PDQ_Valid_MaxLength');
			define_tag:'PDQ_Valid_MaxLength', -Required='Input', -Required='Size';
					Local:'a_input' = String(#Input);
					Local:'a_size' = Integer(#Size);
					if: #a_input->Size <= #a_size;
							Return: true;
					else;
							Return: false;
					/if;
			/define_tag;
	/If;
	
	
	
	
	
	
	
	
	/*
		PDQ_Valid_MinLength
		
		Returns (true|false)
		
		Checks to see whether a supplied value is longer than the supplied allowed value
		
		       minValue: compares submitted value to minValue
		          input: integer | decimal | date | dateTime | time
		        returns: true | false
	*/
	$PDQ_ValidationKeys->insert('minLength');
	$PDQ_ValidationTags->insert('minLength'='PDQ_Valid_MinLength');
	If: !(Lasso_TagExists: 'PDQ_Valid_MinLength');
			define_tag:'PDQ_Valid_MinLength', -Required='Input', -Required='Size';
					Local:'a_input' = String(#Input);
					Local:'a_size' = Integer(#Size);
					if: #a_input->Size >= #a_size;
							Return: true;
					else;
							Return: false;
					/if;
			/define_tag;
	/If;
	
	
	
	
	
	
	
	
	/*
		PDQ_Valid_Numeric
		
		Returns (true|false)
		
		Checks to see whether a supplied value is numeric string
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Numeric');
			define_tag:'PDQ_Valid_Numeric', -Required='Input';
					Local:'a_input' = String(#Input);
					if: (params) >> -Strict;
							iterate: #a_input, local: 'a_char';
									if: (String_IsNumeric(#a_char) == false);
											return: false;
									/if;
							/iterate;
					else;
							iterate: #a_input, local: 'a_char';
									if: #a_char != ' ';
											if: (String_IsNumeric(#a_char) == false);
													return: false;
											/if;
									/if;
							/iterate;
					/if;
					Return: true;
			/define_tag;
	/If;





	/*
		PDQ_Valid_Integer
		
		Returns (true|false)
		
		Checks to see whether a supplied value is a valid integer
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Integer');
			define_tag:'PDQ_Valid_Integer', -Required='Input';
					Local:'a_input' = String(#Input);
					iterate: #a_input, local: 'a_char';
						if: (String_IsNumeric(#a_char) == false);
								return: false;
						/if;
					/iterate;
					#a_input = integer(#Input);
					
					Return(true);
			/define_tag;
	/If;






	/*
		PDQ_Valid_Decimal
		
		Returns (true|false)
		
		Checks to see whether a supplied value is a valid decimal
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Decimal');
			define_tag:'PDQ_Valid_Decimal', -Required='Input';
					Local:'a_input' = String(#Input);
					iterate: #a_input, local: 'a_char';
						if: #a_char != '.';
								if: (String_IsNumeric(#a_char) == false);
										return: false;
								/if;
						/if;
					/iterate;
					#a_input = decimal(#Input);
					
					Return(true);
			/define_tag;
	/If;






	/*
		PDQ_Valid_AlphaNumeric
		
		Returns (true|false)
		
		Checks to see whether a supplied value is alhpa-numeric string
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_AlphaNumeric');
			define_tag:'PDQ_Valid_AlphaNumeric', -Required='Input';
					Local:'a_input' = String(#Input);
					if: (params) >> -Strict;
							iterate: #a_input, local: 'a_char';
									if: #a_char->IsAlnum == false;
											return: false;
									/if;
							/iterate;
					else;
							iterate: #a_input, local: 'a_char';
									if: #a_char != ' ';
											if: #a_char->IsAlnum == false;
													return: false;
											/if;
									/if;
							/iterate;
					/if;
					Return: true;
			/define_tag;
	/If;


	/*
		PDQ_Valid_Alpha
		
		Returns (true|false)
		
		Checks to see whether a supplied value is alphabetic-only
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Alpha');
			define_tag:'PDQ_Valid_Alpha', -Required='Input';
					Local:'a_input' = String(#Input);
					if: (params) >> -Strict;
							iterate: #a_input, local: 'a_char';
									if: #a_char->IsAlpha == false;
											return: false;
									/if;
							/iterate;
					else;
							iterate: #a_input, local: 'a_char';
									if: #a_char != ' ';
											if: #a_char->IsAlpha == false;
													return: false;
											/if;
									/if;
							/iterate;
					/if;
					Return: true;
			/define_tag;
	/If;




	/*
		PDQ_Valid_MaxValue
		
		Returns (true|false)
		
		Checks to see whether a supplied value is longer than the supplied allowed value
		
		
		       maxValue: compares submitted value to maxValue, based on dataType
		          input: integer | decimal | date | dateTime | time
		        returns: true | false
	*/
	$PDQ_ValidationKeys->insert('maxValue');
	$PDQ_ValidationTags->insert('maxValue'='PDQ_Valid_MaxValue');
	If: !(Lasso_TagExists: 'PDQ_Valid_MaxValue');
			define_tag:'PDQ_Valid_MaxValue', -Required='Input', -Required='Max';
					// Max
					if: (String_IsNumeric(#Max));
							Local:'a_value' = integer(#Max);
					else: #Max->Isa: 'date';
							// max is a date
							Local:'a_value' = date(#Max);
					else: (PDQ_Valid_Date: #Max);
							// max is a date
							Local:'a_value' = date(#Max);
					else: #Max->Isa: 'string';
							// Max is a string
							if: (PDQ_Valid_Alpha: #Max, -Strict);
									// Max is not numeric
									return: 'Error - Max must be a valid date, decimal, or integer.';
							else: #Max >> '.';
									// convert to a decimal
									Local:'a_value' = decimal(#Max);
							else: (PDQ_Valid_Date: #Max);
									// convert to a date
									Local:'a_value' = date(#Max);
							else;
									Local:'a_value' = integer(#Max);
							/if;
					else: #Max->Isa: 'integer';
							Local:'a_value' = integer(#Max);
					else: #Max->Isa: 'decimal';
							Local:'a_value' = decimal(#Max);
					else;
							return: 'Error - Max must be a valid date, decimal, or integer.';
					/if;
					
					
					
					
					
					// Input
					if: (String_IsNumeric(#Input));
							Local:'a_input' = integer(#Input);
					else: boolean(PDQ_Valid_Date: #Input);
							Local:'a_input' = date(#Input);
					else: #Input->Isa: 'string';
							if: (PDQ_Valid_Alpha: #Input, -Strict);
									return(false);
							else: #Input >> '.';
									// convert to a decimal
									Local:'a_input' = decimal(#Input);
							else;
									Local:'a_input' = integer(#Input);
							/if;
					else: #Input->Isa: 'integer';
							Local:'a_input' = integer(#Input);
					else: #Input->Isa: 'decimal';
							Local:'a_input' = decimal(#Input);
					else;
							return: false;
					/if;
					
					
					if: #a_value->Isa: 'date' && #a_input->Isa: 'string';
							return(false);
					/if;
					
					if: #a_value->Isa: 'date' && #a_input->Isa: 'integer';
							return(false);
					/if;
					
					if: #a_input <= #a_value;
							Return: true;
					else;
							Return: false;
					/if;
			/define_tag;
	/If;


	/*]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	Valid_Phone
	
	Returns { true | false } depending upon whether the input is valid or not.
	
	 ^(\(?\d\d\d\)?)?[ -]?\d\d\d[ -]?\d\d\d\d$
	
	 ^(\(?\d\d\d\)?)?[ -]?\d\d\d[ -]?\d\d\d\d$ -- loose
	 ^(\(\d\d\d\) )?\d\d\d[ -]\d\d\d\d$ -- strict

	------------------------------------------------------------------ Chris Corwin ---->
	[*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Phone');
			define_tag:'PDQ_Valid_Phone', -Required='Input';
					Local:'a_number' = (String: #Input);
					Local: 'regex_Loose' = '^(\\(?\\d\\d\\d\\)?)?[ -]?\\d\\d\\d[ -]?\\d\\d\\d\\d$';
					Local: 'regex_Strict' = '^(\\(\\d\\d\\d\\) )?\\d\\d\\d[ -]\\d\\d\\d\\d$';
					if: (params) >> -Strict;
							Local: 'a_regex' = @#regex_strict;
					else;
							Local: 'a_regex' = @#regex_loose;
					/if;
					Return: (Boolean: (String_FindRegExp: #a_number, -Find=#a_regex)->Size);
			/define_tag;
	/If;






	/*
		PDQ_Valid_SSN
		
		Returns { true | false } depending upon whether the input is valid or not.
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_SSN');
			define_tag:'PDQ_Valid_SSN', -Required='Input';
					Local:'a_number' = (String: #Input);
					if: (params) >> -Strict;
							Return: (Boolean: (String_FindRegExp: #a_number, -Find='^\\d{3}\\-\\d{2}\\-\\d{4}$')->Size);
					else;
							Return: Boolean:((String_FindRegExp: #a_number, -Find='^\\d{3}[\\-]*\\d{2}[\\-]*\\d{4}$')->Size);
					/if;
			/define_tag;
	/If;





	/*
		PDQ_Valid_Email
		
		Returns { true | false } depending upon whether the input is valid or not.
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Email');
			define_tag:'PDQ_Valid_Email', -Required='Input';
					local: 'emailPatterns' =
						Array(
							'.+@.+\\..+$',
							'^\\w.+@\\w.+\\.[a-z]+$',
							'^\\w[-_a-z~.]+@\\w[-_a-z~.]+\\.[a-z]{2}[a-z]*$',
							'^\\w[\\w\\d]+(\\.[\\w\\d]+)*@\\w[\\w\\d]+(\\.[\\w\\d]+)*\\.[a-z]{2,7}$',
							)
						;
					local:'a_input' = String(#Input);
					
					iterate: #emailPatterns, local: 'a_pattern';
							if: boolean((String_FindRegExp: #a_input, -Find=#a_pattern)->Size);
							else;
								return(false);
							/if;
							return(true);
					/iterate;
			/define_tag;
	/If;

	If: !(Lasso_TagExists: 'PDQ_Email_Obscure');
			define_tag:'PDQ_Email_Obscure', -Required='Input';
					local:'a_input' = String(#Input);
					#a_input = string_ReplaceRegExp(#a_input,-Find='\\@', -Replace='&nbsp;(at)&nbsp;');
					#a_input = string_ReplaceRegExp(#a_input,-Find='\\.', -Replace='&nbsp;(dot)&nbsp;');
					return(#a_input);
			/define_Tag;
	/if;



	/*
		PDQ_Valid_URL
		
		Returns { true | false } depending upon whether the input is valid or not.
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_URL');
			define_tag:'PDQ_Valid_URL', -Required='Input';
					local: 'patterns' =
						Array(
							'((http|ftp|https):\\/\\/)*(([\\w-]+\\.)+)([\\w-]+)(\\?*[\\w=\\&\\ ]*)',
							)
						;
					local:'a_input' = String(#Input);
					iterate: #patterns, local: 'a_pattern';
							if: boolean((String_FindRegExp: #a_input, -Find=#a_pattern)->Size);
							else;
								return(false);
							/if;
							return(true);
					/iterate;
			/define_tag;
	/If;













	define_tag:'lw_file_exists',-priority='replace',-required='filename';
		local:'out' = false;
		protect;
			#out = (boolean: ((include_raw: #filename)->size));
		/protect;
		return: #out;
	/define_tag;

	define_tag:'mhc_decrypt_blowfish',-priority='replace';
		local:'params' = params;
	
		local:'seedling' = null;
		if: #params->(find:'-seed')->size;
			#seedling = #params->(find:'-seed')->(get:1)->value;
			#params->(remove: (#params->(findposition:'-seed')->(get:1)));
		/if;
	
		local:'encrypted_string' = null;
		if: #params->size;
			if: #params->(get:1)->type == 'pair';
				#encrypted_string = #params->(get:1)->value;
			else;
				#encrypted_string = #params->(get:1);
			/if;
		/if;
	
		protect;
			handle_error;
				return: #encrypted_string;
			/handle_error;
			return: (decrypt_blowfish: -Seed=#seedling, #encrypted_string);
		/protect;
	
	/define_tag;







	If: !(Lasso_TagExists: 'PDQ_Navbar');
			Define_Tag: 
				'PDQ_Navbar',
				-Required='thisNavBar',
				-Required='navbarStyleInfo'
				;
					Local: 'nextButtonState' = '';
					
					Local: 'output' = (String);
					
					
					
					Iterate: (Var: #thisNavBar), Local: 'a_thing';
							Local: 'button_' + (Loop_Count) + '_' + 'Label' = (#a_thing->(Find: 'Label'));
							Local: 'button_' + (Loop_Count) + '_' + 'Link' = (#a_thing->(Find: 'Path'));
							Local: 'button_' + (Loop_Count) + '_' + 'Title' = (#a_thing->(Find: 'Title'));
							Local: 'button_' + (Loop_Count) + '_' + 'Class' = (#a_thing->(Find: 'Class'));
							Local: 'button_' + (Loop_Count) + '_' + 'Disabled' = (#a_thing->(Find: 'disabled'));
					/Iterate;
					
					
					if(#thisNavBar->size);
					
					
					#output += '<ul ' #navbarStyleInfo ' >';
							Iterate: (Var: #thisNavBar), Local: 'a_thing';
									Local: 'thisLink' = (Local: 'button_' + (Loop_Count) + '_' + 'Link', -EncodeNone);
									/*]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
									Sets up and down state for a tags
									------------------------------------------------------------->
									[*/
									Loop: $thisLevel_Number;
											Local: 'pathsMatchFlag' = (Var: 'pathTo_Level_' + (Loop_Count))->(Contains: #thisLink);
											If: #pathsMatchFlag == true;
													Local: 'buttonState' = 'down';
											Else;
													Local: 'buttonState' = 'up';
											/If;
									/Loop;
									If: (Response_Path) != '/';
											If: #thisLink == '/';
													Local: 'buttonState' = 'up';
											/If;
									/If;
									If: #nextButtonState == 'down-helper';
											#buttonState = 'down-helper';
											#nextButtonState = '';
									/If;
									If: #buttonState == 'down';
											Local: 'nextButtonState' = 'down-helper';
									Else;
											Local: 'nextButtonState' = '';
									/If;
									#output += '<li class="' #buttonState '" >';
											If: (Variable_Defined: 'Navbar_LinkPrefix') == true;
													#output += $Navbar_LinkPrefix;
											/If;
											local: 'a_displayName' = (Local: 'button_' + (Loop_Count) + '_' + 'Label');
											If: #a_displayName >> '_';
													local: 'new_displayName' = (#a_displayName->(Split: '_'));
													#a_displayName = #new_displayName->(Join: '&nbsp;');
											/If;
											if(!((Local: 'button_' + (Loop_Count) + '_' + 'Disabled') == true));
													#output += '<a href="';
													#output += #thisLink;
													#output += '" ';
													#output += 'title="';
													#output += (Local: 'button_' + (Loop_Count) + '_' + 'Title');
													#output += '" ';
													#output += 'class="';
													#output += (Local: 'button_' + (Loop_Count) + '_' + 'Class');
													#output += '" ';
													#output += ' >';
											else;
													#output += '<span class="'(Local: 'button_' + (Loop_Count) + '_' + 'Class')'">';
													
											/if;
											#output += #a_displayName;
											if(!((Local: 'button_' + (Loop_Count) + '_' + 'Disabled') == true));
													#output += '</a>';
											else;
													#output += '</span>';
											/if;
											If: (Variable_Defined: 'Navbar_LinkSuffix') == true;
													#output += $Navbar_LinkSuffix;
											/If;
									#output += '</li>';
							/Iterate;
					#output += '</ul>';
					
					
					/if;
					
					Return: @#output;
			/Define_Tag;
	/If;

	If: !(Lasso_TagExists: 'Create_UID_20');
			Define_Tag: 
				'Create_UID_20'
				;
					Local: 'UID_Characters' = 'AaBb9CcDd8EeFf7GgHh6iJj5KkLm4NnoPp3QqRr2SsTt1UuVv9WwXx8YyZz';
					Local: 'UID_StringLength' = 20;
					Local: 'newUID' = (String);
					Loop: #UID_StringLength;
							Local: 
								'a_Character'
								 = 
								#UID_Characters->
									(Get: 
										(Math_Random: 
											-Min=1, 
											-Max=(#UID_Characters->Size)
											)
										)
								;
							#newUID += #a_Character;
					/Loop;
					Return: #newUID;
			/Define_Tag;
	/If;

/*
============================================================
"Phone_Format"
Author: Randy Phillips
Company: phillipsIT
Date: 11/29/2002
This tag places separators in phone numbers that are cast as
integers in the database.
Usage: (Phone_Format: -number=(field:'phone'), -separator='-')
˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
*/
	If: !(Lasso_TagExists: 'PDQ_Phone_Format');
			define_tag:'PDQ_Phone_Format';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				Select: #number->Size;
						Case: 10;
								Local:'string' = (string_insert:(string_insert:#number, -position=4, -text=@#separator), -position=8, -text=@#separator);
						Case: 7;
								Local:'string' = (string_insert: #number, -position=4, -text=@#separator);
						Case: 0;
								Local:'string' = '(unavailable)';
						Case;
								Local:'string' = (string_insert:(string_insert:#number, -position=3, -text=@#separator), -position=7, -text=@#separator);
				/Select;
				return(#string);
			/define_tag;
	/If;
	
	If: !(Lasso_TagExists: 'PDQ_Phone_FormDisplay');
			define_tag:'PDQ_Phone_FormDisplay';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				Select: #number->Size;
						Case: 10;
								Local:'string' = (string_insert:(string_insert:#number, -position=4, -text=@#separator), -position=8, -text=@#separator);
						Case: 7;
								Local:'string' = (string_insert: #number, -position=4, -text=@#separator);
						Case: 0;
								Local:'string' = '';
						Case;
								Local:'string' = (string_insert:(string_insert:#number, -position=3, -text=@#separator), -position=7, -text=@#separator);
				/Select;
				return(#string);
			/define_tag;
	/If;
	
	
	If: !(Lasso_TagExists: 'PDQ_SSN_Format');
			define_tag:'PDQ_SSN_Format';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				local: 'new_number' = string;
				iterate: #number, local: 'a_char';
						if: loop_count >= 6;
								#new_number += #a_char;
						else;
								#new_number += 'x';
						/if;
				/iterate;
				Select: #number->Size;
						Case: 9;
								Local:'string' = (string_insert:(string_insert:#new_number, -position=4, -text=@#separator), -position=7, -text=@#separator);
						Case;
								Local:'string' = #new_number;
				/Select;
				return(#string);
			/define_tag;
	/If;

	If: !(Lasso_TagExists: 'PDQ_SSN_FormatUnsafe');
			define_tag:'PDQ_SSN_FormatUnsafe';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				local: 'new_number' = string;
				iterate: #number, local: 'a_char';
						if: loop_count >= 6;
								#new_number += #a_char;
						else;
								#new_number += #a_char;
						/if;
				/iterate;
				Select: #number->Size;
						Case: 9;
								Local:'string' = (string_insert:(string_insert:#new_number, -position=4, -text=@#separator), -position=7, -text=@#separator);
						Case;
								Local:'string' = #new_number;
				/Select;
				return(#string);
			/define_tag;
	/If;
	
	If: !(Lasso_TagExists: 'PDQ_GetKeyValue');
			define_tag:'PDQ_GetKeyValue';
					return(Field: var($rewAction + '_UIDfieldName'));
			/define_tag;
	/if;



/*
============================================================
"Date_Relative"
˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
Returns "Today — 08:53:34 AM" if a date is since midnight
this morning, or as 
Usage: (Date_Relative: (Date));

˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
*/
	If: !(Lasso_TagExists: 'PDQ_Date_Relative');
			Define_Tag: 'PDQ_Date_Relative', -required='this';
					Local:
						'a_Date' = date(#this),
						'Now' = (Date),
						'Midnight' = date((date)->Format('%Y-%m-%d')),
						;
					if(#this == '');
							return('--');
					/if;
					Local: 'MidnightTonight' = #Midnight; 
					#MidnightTonight->(Add: (Duration: '24:00:00')); 
					Local: 'difference_DateToNow' = (#a_Date->(Difference: #Now, -Second));
					Local: 'difference_MidnightToNow' = (#Midnight->(Difference: #Now, -Second));
					Local: 'difference_NowToMidnightTonight' = (#Now->(Difference: #MidnightTonight, -Second));
					#difference_NowToMidnightTonight *= (-1);
					If: #difference_DateToNow <= (#difference_NowToMidnightTonight * 2 - #difference_MidnightToNow);
							If: (#a_Date->Year) > (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ', (' 
										+ (#a_Date->Year) 
										+ ') &#8212; ' 
										+ (Date_Format: #a_Date, -Format='%_h:%M %p')
										;
							Else;
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' &#8212; ' 
										+ (Date_Format: #a_Date, -Format='%_h:%M %p')
										;
							/If;
					Else: #difference_DateToNow <= #difference_NowToMidnightTonight;
							Local:'display' = 
								(
									'Tomorrow &#8212; ' 
									+ (Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= 0;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= #difference_MidnightToNow;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= (#difference_MidnightToNow + (24 * 60 * 60));
							Local:'display' = 
								(
									'Yesterday &#8212; ' 
									+ (Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: (#a_Date->Year) < (Date->Year);
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								+ ', (' 
								+ (#a_Date->Year) 
								+ ') &#8212; ' 
								+ (Date_Format: #a_Date, -Format='%_h:%M %p')
								;
					Else;
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								+ ' &#8212; ' 
								+ (Date_Format: #a_Date, -Format='%_h:%M %p')
								;
					/If;
					return(#display);
			/Define_Tag;
	/If;
	
	
	


/*
============================================================
"Date_Relative"
˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
Returns "Today — 08:53:34 AM" if a date is since midnight
this morning, or as 
Usage: (Date_Relative: (Date));

˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
*/
	If: !(Lasso_TagExists: 'Date_Display');
			Define_Tag: 'Date_Display', -required='this';
					if: #this == '';
							return('--');
					/if;
					Local:
						'a_Date' = date(#this),
						;
					if: #a_Date == date('0000-00-00 00:00:00');
							return('--');
					else: #a_Date == date('0000-01-01 00:00:00');
							return('--');
					else;
							If: (#a_Date->Year) > (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ', ' 
										+ (#a_Date->Year) 
										+ '' 
										;
							else: (#a_Date->Year) < (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ', ' 
										+ (#a_Date->Year) 
										+ '' 
										;
							Else;
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										;
							/If;
							return(#display);
					/if;
					Local: 'MidnightTonight' = #Midnight; 
					#MidnightTonight->(Add: (Duration: '24:00:00')); 
					Local: 'difference_DateToNow' = (#a_Date->(Difference: #Now, -Second));
					Local: 'difference_MidnightToNow' = (#Midnight->(Difference: #Now, -Second));
					Local: 'difference_NowToMidnightTonight' = (#Now->(Difference: #MidnightTonight, -Second));
					#difference_NowToMidnightTonight *= (-1);
					
					
					If: #difference_DateToNow <= (#difference_NowToMidnightTonight * 2 - #difference_MidnightToNow);
							If: (#a_Date->Year) > (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' ' 
										+ (#a_Date->Year) 
										+ '' 
										;
							Else;
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' &#8212;' 
										;
							/If;
					Else: #difference_DateToNow <= #difference_NowToMidnightTonight;
							Local:'display' = 
								(
									'Tomorrow' 
								)
								;
					Else: #difference_DateToNow <= 0;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= #difference_MidnightToNow;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= (#difference_MidnightToNow * 2);
							Local:'display' = 
								(
									'Yesterday' + (#a_date)
								)
								;
					Else: (#a_Date->Year) < ((date)->Year);
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								+ ' (' 
								+ (#a_Date->Year) 
								+ ')' 
								;
					Else;
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								;
					/If;
					return(#display);
			/Define_Tag;
	/If;


	
	If: !(Lasso_TagExists: 'PDQ_SSN_PrepForDb');
			define_tag:'PDQ_SSN_PrepForDb';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
	/If;
	
	
	
	If: !(Lasso_TagExists: 'PDQ_Phone_PrepForDb');
			define_tag:'PDQ_Phone_PrepForDb';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
	/If;
	
	If: !(Lasso_TagExists: 'PDQ_ShortNote');
			define_tag:'PDQ_ShortNote', -required='Input';
					local: 'maxCharacters' = 50;
					local: 'a_string' = #Input;
					local: 'a_output' = string;
					if: #a_string->size <= #maxCharacters;
							#a_output += #a_string;
					else;
							//split on the fist period-space combo
							local: 'a_array' = #a_string->split('. ');
							#a_output = #a_array->First;
							if: #a_output->size < #maxCharacters;
									#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' $REW_Review '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
							else;
									//split on the fist period-space combo
									#a_output = string;
									local: 'a_array' = #a_string->split('. ');
									#a_output = #a_array->First;
									
									if: #a_output->size < #maxCharacters;
											#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' $REW_Review '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									else;
											#a_output = #a_output->substring(0, #maxCharacters) + @'&hellip;' + (encode_smart('&nbsp;<a href="' $REW_Review '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									/if;
							/if;
					/if;
					return(@(#a_output));
			/define_tag;
	/if;


	if: !(lasso_tagexists('Retrieve_HistoryEventTypes'));
			define_tag: 'Retrieve_HistoryEventTypes';
					local: 'gettypes' = '
						SELECT historyEventTypeUID, label FROM historyEventTypes
						WHERE historyEventTypeUID IS NOT NULL
						OR historyEventTypeUID != ""
						ORDER BY label ASC
						';
					local: 'result' = (array);
					inline:
						$connection_db,
						-sql=#gettypes,
						-table='historyEventTypes',
						-inlinename='historyEventTypes',
						-maxrecords='all'
						;
							rows;
									#result->Insert(Field('historyEventTypeUID')=Field('label'));
							/rows;
					/inline;
					return(#result);
			/define_Tag;
	/if;
	
	
	
	
	
	if: !(lasso_tagexists('FixLayout'));
			define_tag: 'FixLayout';
					Return(@('<p class="">(temporary layout issue being fixed here)</p>'));
			/define_tag;
	/if;
	


	define_tag:'lw_file_exists',-priority='replace',-required='filename';
		local:'out' = false;
		protect;
			#out = (boolean: ((include_raw: #filename)->size));
		/protect;
		return: #out;
	/define_tag;

	define_tag:'mhc_decrypt_blowfish',-priority='replace';
		local:'params' = params;
	
		local:'seedling' = null;
		if: #params->(find:'-seed')->size;
			#seedling = #params->(find:'-seed')->(get:1)->value;
			#params->(remove: (#params->(findposition:'-seed')->(get:1)));
		/if;
	
		local:'encrypted_string' = null;
		if: #params->size;
			if: #params->(get:1)->type == 'pair';
				#encrypted_string = #params->(get:1)->value;
			else;
				#encrypted_string = #params->(get:1);
			/if;
		/if;
	
		protect;
			handle_error;
				return: #encrypted_string;
			/handle_error;
			return: (decrypt_blowfish: -Seed=#seedling, #encrypted_string);
		/protect;
	
	/define_tag;


	if: !(lasso_tagexists('Retrieve_HistoryEventTypes'));
			define_tag: 'Retrieve_HistoryEventTypes';
					local: 'gettypes' = '
						SELECT historyEventTypeUID, label FROM historyEventTypes
						WHERE historyEventTypeUID IS NOT NULL
						OR historyEventTypeUID != ""
						ORDER BY label ASC
						';
					local: 'result' = (array);
					inline:
						$connection_db,
						-sql=#gettypes,
						-table='historyEventTypes',
						-inlinename='historyEventTypes',
						-maxrecords='all',
						;
							rows;
									#result->Insert(Field('historyEventTypeUID')=Field('label'));
							/rows;
					/inline;
					return(#result);
			/define_Tag;
	/if;
	
	
	
	
	
	if: !(lasso_tagexists('FixLayout'));
			define_tag: 'FixLayout';
					Return(@('<p class="">(temporary layout issue being fixed here)</p>'));
			/define_tag;
	/if;
	
	
	
	
	if( ! lasso_tagexists:('Lasso_Pimp'));
			define_tag:(
				'Lasso_Pimp'
				);
					Redirect_URL:('http://www.lassopimp.com');
			/define_tag;
	/if;


	
	
//	If: !(Lasso_TagExists: 'PDQ_ContentHeader');
			define_tag:'PDQ_ContentHeader', -priority='replace';
				local: 'outttishh' = string;
				#outttishh += '<div class="tab-left">';
				if($apparentUserTypeShortName == 'CompAdmin');
						#outttishh += '<div class="companyName">'(MHC_User_GetCompanyNameLong)'</div>';
				/if;
				#outttishh += '<h1>';

				if: response_filepath >> '/Monitor/Add/Patient/';
					local: 'get_patient' = 'SELECT * FROM ' + $siteDB + '.patients WHERE patientUID = "' ($monitoraddpatient_patient->(find:'patientUID')) '" LIMIT 1 ';
					Inline:
						$connection_db,
						-SQL=#get_patient;
						rows;
								var: 'patientUID' = (Field:'patientUID');
								var: 'patient_firstName' = (Field:'firstName');
								var: 'patient_lastName' = (Field:'lastName');
						/rows;					
					/inline;
					#outttishh += '<span class="detailName"><a href="/Patient/Info/"><span class="cap">' (String_LowerCase($patient_LastName))', '(String_LowerCase($patient_FirstName))'</span></a></span>';
				/if;
				
// 				if: variable_defined: 'patient_name';
// 						#outttishh += $patient_name;
// 				/if;

				(var('detailName') != '') ? #outttishh += ('<span class="detailName"><a href="' $rewAction_DetailPage_pathTo '">'  $detailName '</a></span>') | #outttishh += '';
				local('levelsSoFar'=string);
				iterate: $levels, local: 'this_level';
						if: #this_level != 'Home';
								#levelsSoFar += #this_level '/';
								if: loop_count == $levels->size;
										#outttishh += '<span class="';
										#outttishh += 'last';
								else;
										#outttishh += '<span class="';
										#outttishh += 'no' loop_count;
								/if;
								local: 'a_displayName' = #this_level;
								If: #a_displayName >> '_';
										local: 'new_displayName' = (#a_displayName->(Split: '_'));
										#a_displayName = #new_displayName->(Join: '&nbsp;');
								/If;
								if: loop_count == $levels->size;
										#outttishh += '">';
								else;
										#outttishh += '">';
								/if;
								if(loop_count == 2);
										inline:
											$connection_files,
											-nothing,
											;
												If: (File_Exists: '/_Assets/Images/title_' #this_level '.jpg') == true;
														#outttishh += '<img src="/_Assets/Images/title_' #this_level '.jpg" alt="" />';
														#outttishh +=  '&nbsp;';
												/if;
										/inline;
								/if;
								#outttishh += (#this_level != $thisLevel_Name ? '<a href="/' #levelsSoFar '">');
								#outttishh += #a_displayName;
								#outttishh += (#this_level != $thisLevel_Name ?'</a>');
								#outttishh +=  (loop_count != $levels->size ? '\r&gt;');
								#outttishh += '</span>\r\t\t';
								
						/if;
				/iterate;
				#outttishh += (  '</h1></div>');
				return(#outttishh);
			/define_tag;
//	/If;
	
	If: !(Lasso_TagExists: 'PDQ_SSN_PrepForDb');
			define_tag:'PDQ_SSN_PrepForDb';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
	/If;
	
	
	If: !(Lasso_TagExists: 'PDQ_Phone_PrepForDb');
			define_tag:'PDQ_Phone_PrepForDb';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
	/If;

	If: !(Lasso_TagExists: 'PDQ_Phone_FormDisplay');
			define_tag:'PDQ_Phone_FormDisplay';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				Select: #number->Size;
						Case: 10;
								Local:'string' = (string_insert:(string_insert:#number, -position=4, -text=@#separator), -position=8, -text=@#separator);
						Case: 7;
								Local:'string' = (string_insert: #number, -position=4, -text=@#separator);
						Case: 0;
								Local:'string' = '';
						Case;
								Local:'string' = (string_insert:(string_insert:#number, -position=3, -text=@#separator), -position=7, -text=@#separator);
				/Select;
				return(#string);
			/define_tag;
	/If;


	
	namespace_using('PDQ_');

			define_tag(
				'Phone', 
				-namespace='Valid_',
				-priority='replace',
				-description='Returns (true|false) depending upon whether the input is valid or not. Has an optional -Strict parameter.',
				-Required='Input'
				);
					fail_if(
						!params->size,
						-1,
						'[Valid_Phone] requires a requires at least one parameter.'
					);
					
					local(
						'a_number' = string(#Input),
						'regex_Loose' = '^(\\(?\\d\\d\\d\\)?)?[ -]?\\d\\d\\d[ -]?\\d\\d\\d\\d$',
						'regex_Strict' = '^(\\(\\d\\d\\d\\) )?\\d\\d\\d[ -]\\d\\d\\d\\d$'
						);
					if: (params) >> -Strict;
							Local: 'a_regex' = @#regex_strict;
					else;
							Local: 'a_regex' = @#regex_loose;
					/if;
					return(boolean(string_FindRegExp( #a_number, -Find=#a_regex)->size));
			/define_tag;
			
			
			define_tag(
				'SSN', 
				-namespace='Valid_',
				-priority='replace',
				-description='Returns (true|false) depending upon whether the input is valid or not. Has an optional -Strict parameter.',
				-Required='Input'
				);
					fail_if(
						!params->size,
						-1,
						'[Valid_SSN] requires a requires at least one parameter.'
					);
					
					local(
						'a_number' = string(#Input),
						'regex_Loose' = '^\\d{3}[\\-]*\\d{2}[\\-]*\\d{4}$',
						'regex_Strict' = '^\\d{3}\\-\\d{2}\\-\\d{4}$'
						);
					if: (params) >> -Strict;
							Local: 'a_regex' = @#regex_strict;
					else;
							Local: 'a_regex' = @#regex_loose;
					/if;
					return(boolean(string_FindRegExp( #a_number, -Find=#a_regex)->size));
			/define_tag;
			
			
			
			define_tag(
				'SSN',
				-namespace='PrepForDb_',
				-priority='replace',
				-description='Strips delimeters from a alphanumeric string, such as a SSN.'
				);
				local('number' = (params)->get(1));
				local('number' = string_ReplaceRegExp(#number,-Find='([^\\w\\d]+)',-Replace=''));
				return(#number);
			/define_tag;
			
			
			define_tag(
				'Phone',
				-namespace='PrepForDb_',
				-priority='replace',
				-description='Strips delimeters from a alphanumeric string, such as a phone number.'
				);
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
			
	
			define_tag:'PDQ_SSN_Format';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				local: 'new_number' = string;
				iterate: #number, local: 'a_char';
						if: loop_count >= 6;
								#new_number += #a_char;
						else;
								#new_number += 'x';
						/if;
				/iterate;
				Select: #number->Size;
						Case: 9;
								Local:'string' = (string_insert:(string_insert:#new_number, -position=4, -text=@#separator), -position=7, -text=@#separator);
						Case;
								Local:'string' = #new_number;
				/Select;
				return(#string);
			/define_tag;
			
			
			define_tag:'PDQ_SSN_FormatUnsafe';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				local: 'new_number' = string;
				iterate: #number, local: 'a_char';
						if: loop_count >= 6;
								#new_number += #a_char;
						else;
								#new_number += #a_char;
						/if;
				/iterate;
				Select: #number->Size;
						Case: 9;
								Local:'string' = (string_insert:(string_insert:#new_number, -position=4, -text=@#separator), -position=7, -text=@#separator);
						Case;
								Local:'string' = #new_number;
				/Select;
				return(#string);
			/define_tag;
			
	/namespace_using;
	
	
	
	define_tag(
		'pathfromroot',
		-namespace='file_',
		-priority='replace',
		-description='Converts a relative path to a root path.'
	);
		fail_if(
			!params->size || !params->first->isa('string'),
			-1,
			'[file_pathfromroot] requires a file path as a parameter.'
		);
		
		local('in' = params->first);
		
		if(#in->beginswith('/'));
			return(#in);
		else(#in->beginswith('../'));
			local('steps' = #in->split('../')->size - 1);
			local('out' = '/');
			
			iterate(response_path->split('/'), local('i'));
				loop_count > 1 ? #out += #i + '/';
				loop_count == #steps ? loop_abort;
			/iterate;
			
			#out += #in;
			return(#in);
		else;
			return(response_path + #in);
		/if;
	/define_tag;

	if(!(lasso_tagExists('PDQ_ShortNote')));
			define_tag(
				'once',
				-namespace='include_',
				-priority='replace',
				-description='Includes the specified file only if it has not already been included.'
			);
				fail_if(
					!params->size || !params->first->isa('string'),
					-1,
					'[include_once] requires a file path as a parameter.'
				);
				
				local('path') = file_pathfromroot(params->first);		
				!var_defined('included_files') ? var('included_files' = set);		
				
				if($included_files !>> #path);
					$included_files->insert(#path);
					return(include(#path));
				/if;		
			/define_tag;
	/if;

	If: !(Lasso_TagExists: 'PDQ_ShortNote');
			define_tag:'PDQ_ShortNote', -required='Input';
					local: 'maxCharacters' = 50;
					local: 'a_string' = #Input;
					local: 'a_output' = string;
					if: #a_string->size <= #maxCharacters;
							#a_output += #a_string;
					else;
							//split on the fist period-space combo
							local: 'a_array' = #a_string->split('. ');
							#a_output = #a_array->First;
							if: #a_output->size < #maxCharacters;
									#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
							else;
									//split on the fist period-space combo
									#a_output = string;
									local: 'a_array' = #a_string->split('. ');
									#a_output = #a_array->First;
									
									if: #a_output->size < #maxCharacters;
											#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									else;
											#a_output = #a_output->substring(0, #maxCharacters) + @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									/if;
							/if;
					/if;
					return(@(#a_output));
			/define_tag;
	/if;


	If: !(Lasso_TagExists: 'MHC_Date');
			Define_Tag: 'MHC_Date', -required='this';
					if: #this == '';
							return('no date specified');
					/if;
					Local:
						'a_Date' = date(#this),
						'Now' = (Date),
						'Midnight' = date((date)->Format('%Y-%m-%d')),
						;
					if: #a_Date == date('0000-00-00 00:00:00');
							return('no date specifiied');
					else: #a_Date == date('0000-01-01 00:00:00');
							return('no date specifiied');
					else;
							// return(#a_date);
					/if;
					Local: 'MidnightTonight' = #Midnight; 
					#MidnightTonight->(Add: (Duration: '24:00:00')); 
					Local: 'difference_DateToNow' = (#a_Date->(Difference: #Now, -Second));
					Local: 'difference_MidnightToNow' = (#Midnight->(Difference: #Now, -Second));
					Local: 'difference_NowToMidnightTonight' = (#Now->(Difference: #MidnightTonight, -Second));
					#difference_NowToMidnightTonight *= (-1);
					
					
					If: #difference_DateToNow <= (#difference_NowToMidnightTonight * 2 - #difference_MidnightToNow);
							If: (#a_Date->Year) > (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' (' 
										+ (#a_Date->Year) 
										+ ')' 
										;
							Else;
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' &#8212;' 
										;
							/If;
					Else: #difference_DateToNow <= #difference_NowToMidnightTonight;
							Local:'display' = 
								(
									'Tomorrow' 
								)
								;
					Else: #difference_DateToNow <= 0;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= #difference_MidnightToNow;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= (#difference_MidnightToNow * 2);
							Local:'display' = 
								(
									'Yesterday' + (#a_date)
								)
								;
					Else: (#a_Date->Year) < ((date)->Year);
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								+ ' (' 
								+ (#a_Date->Year) 
								+ ')' 
								;
					Else;
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								;
					/If;
					return(#display);
			/Define_Tag;
	/If;


	If: !(Lasso_TagExists: 'PDQ_ExternalLink');
			define_tag:'PDQ_ExternalLink', -Required='Input';
					local:'a_input' = String(#Input);
					
					if(#a_input->size > 7);
							if(#a_input->beginswith('http://') || #a_input->beginswith('https://'));
							else;
									#a_input = 'http://' + #a_input;
							/if;
							if(PDQ_Valid_URL(#a_input));
									#a_input = '<a href="' + #a_input +'" class="offsite" target="_blank">' + 'link</a>' ;
									return(#a_input);
							else;
									return(#a_input);
							/if;
					else;
							return('--');
					/if;
			/define_Tag;
	/if;


	If: !(Lasso_TagExists: 'Summit_CoDisplay');
			define_tag:'Summit_CoDisplay';
					return(params);
					local:'a_input' = params->first;
					local:'a_URL' = params->second;
					if(#a_URL != '');
							if(#a_URL->beginswith('http://') || #a_URL->beginswith('https://'));
							else;
									#a_URL = 'http://' + #a_URL;
							/if;
					/if;
					if(PDQ_Valid_URL(#a_URL));
							#a_input = '<a href="' + #a_URL +'" class="offsite" target="_blank">' + #a_input + '</a>' ;
							return(#a_input);
					else;
							return(#a_input);
					/if;
			/define_Tag;
	/if;


	if(!Lasso_TagExists('PDQ_Tempo'));
		define_tag('PDQ_Tempo', 
			-required='param');
			return(date(#param)->format('%Y'));
			/* 					return(#param); */
		/define_tag;
	/if;
	if(!Lasso_TagExists('PDQ_GetKeyValue'));
		define_tag('PDQ_GetKeyValue');
			return(Field(var($rewAction + '_UIDfieldName')));
		/define_tag;
	/if;
	
	
	if(!Lasso_TagExists('Summit_PhotoSmall_FromUserUID'));
		define_tag('Summit_PhotoSmall_FromUserUID', -required='input');
			inline($connection_files);
					if(file_exists('/Summit/_Images/' + #input '/small.jpg'));
							return('<img src="/Summit/_Images/' + #input '/small.jpg">');
					/if;
			/inline;
		/define_tag;
	/if;
	
	if(!Lasso_TagExists('Summit_PhotoMedium_FromUserUID'));
		define_tag('Summit_PhotoMedium_FromUserUID', -required='input');
			inline($connection_files);
					if(file_exists('/Summit/_Images/' + #input '/medium.jpg'));
							return('<img src="/Summit/_Images/' + #input '/medium.jpg">');
					/if;
			/inline;
		/define_tag;
	/if;


	If: !(Lasso_TagExists: 'PDQ_ShortNote');
			define_tag:'PDQ_ShortNote', -required='Input';
					local: 'maxCharacters' = 50;
					local: 'a_string' = #Input;
					local: 'a_output' = string;
					if: #a_string->size <= #maxCharacters;
							#a_output += #a_string;
					else;
							//split on the fist period-space combo
							local: 'a_array' = #a_string->split('. ');
							#a_output = #a_array->First;
							if: #a_output->size < #maxCharacters;
									#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
							else;
									//split on the fist period-space combo
									#a_output = string;
									local: 'a_array' = #a_string->split('. ');
									#a_output = #a_array->First;
									
									if: #a_output->size < #maxCharacters;
											#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									else;
											#a_output = #a_output->substring(0, #maxCharacters) + @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									/if;
							/if;
					/if;
					return(@(#a_output));
			/define_tag;
	/if;
	
/*----------------------------------------------------------------------------

[xml_tree]
Extends and simplifies the built-in XML type.

Author: Jason Huck
Last Modified: Jun. 01, 2006
License: Artistic license <http://opensource.org/licenses/artistic-license.php>

Description:
This type provides additional functionality for the built-in XML type, making 
it easier to retrieve values from XML documents when the structure is known. 
It adds the following new member tags:

->atts - Returns a map of the attributes for the current node, instead of an 
array of pairs.

->attribute(string) - Returns the value of the given attribute for the current 
node.

->nodename(index) - Returns the given child node by name. If there are 
multiple nodes of the same name, you can return a specific node by passing an 
index. If no matching child nodes are found, it will look for an attribute by 
that name.

->getnode(string) - Same as ->nodename above. Useful if the node name 
conflicts with an existing member tag, such as "name."

->getnodes - Returns the children of the current node, minus the empty ones 
that ->children generates on its own.


Sample Usage:
var('testxml') = '\
<?xml version="1.0" ?>
<root>
	<record>
		<thing foo="bar">blah</thing>
		<thing foo="meow">moo</thing>
	</record>
</root>';

var('test') = xml_tree($testxml);

$test->record->thing(2)->contents;

-> moo




Downloaded from tagSwap.net on Jun. 04, 2006.
Latest version available from <http://tagSwap.net/xml_tree>.

----------------------------------------------------------------------------*/
		

define_type(
	'tree', 'xml',
	-namespace='xml_',
	-description='Extends and simplifies the built-in XML type.'
);
	define_tag('atts');
		local('out' = map);
		
		iterate(self->attributes, local('i'));
			#out->insert(@#i->first = @#i->second);
		/iterate;
		
		return(@#out);
	/define_tag;
	
	define_tag('attribute', -req='name');
		if(self->attributes->size && self->attributes->find(#name)->size);
		 	return(@self->attributes->find(#name)->first->second);
		else;
			return('');
		/if;
	/define_tag;
	
	define_tag('getNode', -req='nodename', -opt='count');
		local('matches' = array);
		
		iterate(self->children, local('i'));
			#i->name == #nodename ? #matches->insert(@#i);
		/iterate;
		
		if(!#matches->size);
			return(@self->attribute(#nodename));
		else(#matches->size == 1);
			return(@#matches->first);
		else;
			if(local_defined('count'));
				protect;
					return(@#matches->get(integer(#count)));
					
					handle_error;
						return;
					/handle_error;
				/protect;
			else;
				return(@#matches);
			/if;
		/if;
	/define_tag;
	
	define_tag('getnodes');
		local('out') = @self->children;
		
		iterate(#out, local('i'));
			string(#i)->iswhitespace ? #out->remove(loop_count);
		/iterate;
		
		return(@#out);
	/define_tag;
	
	define_tag('_unknowntag');
		if(params->size);
			return(@self->getnode(tag_name, @params->first));
		else;
			return(@self->getnode(tag_name));
		/if;
	/define_tag;
/define_type;





	var: 'PDQ_ValidationKeys' = (array);
	var: 'PDQ_ValidationTags' = (map);
	
	
	
	
	/*
		       datatype: compares the submitted value against the rules allowed for each of the various datatypes
		        returns: true | false
		         inputs: alpha | alphanumeric | date | decimal | email | integer | numeric | phone | ssn | url
		   TO DO inputs: datetime | ip | ipv6 | time | zip | zipPlus4 | creditCard
	*/
	var: 'PDQ_ValidDataTypes' = 
		array(
			'Alpha',
			'AlphaNumeric',
			'Date',
			'Decimal',
			'Email',
			'Integer',
			'Numeric',
			'Phone',
			'SSN',
			'URL',
			)
		;


	iterate: $PDQ_ValidDataTypes, local: 'a_datatype';
			$PDQ_ValidationKeys->insert(#a_datatype);
	/iterate;












	/*
		PDQ_DateFromString
		
		Returns (true|false)
		
		Munges a string to turn it into a date, if it is at all possible
		
	*/
//	If: !(Lasso_TagExists: 'PDQ_DateFromString');
			define_tag:'PDQ_DateFromString', -Required='Input', -priority='replace';
					// see if it's a valid_date
					if: valid_date(#Input);
							// it appears to be valid the way it is
							local: 'a_input' = date(#input)->Format('%Q %H:%M:%S');
							if: string(#a_input) >> '0000-00-00';
							else: string(#a_input) >> '0000';
									local: 'munged_date' = #a_input;
									#munged_date = date(#munged_date);
									#munged_date = string(#munged_date);
									#munged_date = 
										(String_ReplaceRegExp:
											#munged_date,
											-Find='0000',
											-Replace=((date)->Year(-Long)),
											)
										;
									#a_input = #munged_date;
							/if;
							return(date(#a_input));
					else;
							local: 'a_input' = #input;
							
							local('newstring'=string);
							if(#a_input >> '/');
									iterate(string(#a_input), local('a_char'));
											
											if(#a_char >> '/');
													#newstring += '-';
											else;
													#newstring += #a_char;
											/if;
									/iterate;
							/if;
							
							#newstring->size != 0 ? #a_input = date(#newstring);
							
							
							if: #a_input == 'Now';
									return(date);
							/if;
							
							if: #a_input == 'Today';
									return(PDQ_DateFromSTring(date(date->Format('%Q'))));
							/if;
							
							local: 'some_monthNumbers' = (array);
							loop(12);
									#some_monthNumbers->Insert(loop_count);
							/loop;
							local: 'some_months' = (array);
							iterate: #some_monthNumbers, local('a_num');
									local: 'this_num' = integer(date(#a_num '/15/2010')->Month());
									if: #this_num < 10;
											#this_num = string('0' + #this_num);
									/if;
									#some_months->Insert(date(#a_num '/15/2010')->Month(-Long)=#this_num);
									
									#some_months->Insert(date(#a_num '/15/2010')->Month(-Short)=#this_num);
							/iterate;
							
							
							
							
							local: 'some_dayNumbers' = (array);
							loop(7);
									#some_dayNumbers->Insert(loop_count);
							/loop;
							local: 'daysMap' = (map);
							local: 'some_days' = (array);
							iterate: #some_dayNumbers, local('a_num');
									local: 'this_num' = integer(date('01/' #a_num '/2010')->DayOfWeek());
									#some_days->Insert(date('01/' #a_num '/2010')->DayOfWeek(-Long)=#this_num);
									#daysMap->  Insert((date('01/' #a_num '/2010')->DayOfWeek(-Long)=#this_num));
									
									#some_days->Insert(date('01/' #a_num '/2010')->DayOfWeek(-Short)=#this_num);
									#daysMap->Insert((date('01/' #a_num '/2010')->DayOfWeek(-Short)=#this_num));
							/iterate;
							
							
							iterate: #some_days, local: 'a_day';
									if: #a_input == #a_day;
											local: 'a_DayNum' = #a_day->Second;
											local: 'today_DayNum' =((date)->DayOfWeek());
											local: 'tempdate' = (date);
											#tempdate->Add(-Day=#a_dayNum);
											#a_input = #tempdate;
									/if;
							/iterate;
							
							iterate: #some_days, local: 'a_day';
									if: #a_input == ('next ' #a_day->First);
											local: 'a_DayNum' = #a_day->Second;
											local: 'today_DayNum' =((date)->DayOfWeek());
											local: 'tempdate' = (date);
											#tempdate->Add(-Day=#a_dayNum);
											#a_input = #tempdate;
									/if;
							/iterate;
							
							iterate: #some_days, local: 'a_day';
									if: #a_input ==('last ' #a_day->First);
											local: 'a_DayNum' = #a_day->Second;
											local: 'today_DayNum' =((date)->DayOfWeek());
											local: 'tempdate' = (date);
											#tempdate->Subtract(-Day=#a_dayNum);
											#a_input = #tempdate;
									/if;
							/iterate;
							
							
							
							local: 'munged_date' = #a_Input;
							
							// replace any commas with nothing
							#munged_date = 
								(String_ReplaceRegExp:
									#munged_date,
									-Find='(,+)',
									-Replace='',
									)
								;
							
							// replace any / with -
							
							#munged_date = #munged_date->Split(' ');
							local: 'new_split' = array;
							iterate: #munged_date, local: 'a_member';
									if: (integer(#a_member)) > 0 && (integer(#a_member)) < 3;
											#new_split->Insert(string('0' + string(#a_member)));
									else;
											#new_split->Insert(#a_member);
									/if;
							/iterate;
							#munged_date = #new_split;
							
							#munged_date = #munged_date->Join('/');
							
							
							// replace the month
							iterate: #some_months, local: 'a_month';
									if: #a_input >> #a_month->First;
											#munged_date = 
												(String_ReplaceRegExp:
													#munged_date,
													-Find='(' #a_month->First ')',
													-Replace=#a_month->Second,
													)
												;
											local: 'a_input' = #munged_date;
											
											Loop_Abort;
									/if;
							/iterate;
							
							
							local: 'regex' = '([20|19]+\\d\\d)[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])';
							local: 'regex_delimeter' = '[- /.]';
							local: 'regex_day' = '(0[1-9]|[12][0-9]|3[01])';
							local: 'regex_month' = '(0[1-9]|1[012])';
							local: 'regex_year' = '([20|19]+\\d\\d)';
							local: 'patterns_order' = array('normal','us','uk');

							local: 'patterns' = 

								map(
									'normal'=array('year', 'month', 'day'),
									'us'=array('month', 'day', 'year'),
									'uk'=array('day', 'month', 'year')
									),
								;
								
							local: 'exit' = false;
							local: 'output' = '';
							iterate: #patterns_order, local: 'a_pattern';
									local: 'a_regex' = '';
									local: 'this_pattern' = #a_pattern;
									iterate: #patterns->Find(#this_pattern), local: 'a_subPattern';
											#a_regex += local('regex_' + #a_subPattern);
											if: loop_count < #patterns->size;
													#a_regex += #regex_delimeter;
											/if;
									/iterate;
									if: boolean(String_FindRegexp(#a_input, -Find=#a_regex));
											local: 'output' = String_FindRegexp(#a_input, -Find=#a_regex);
											#output->Remove(1);
											#output = #output->Join('/');
											local: 'this' = #output;
											if: valid_date(#output);
													// this may be our baby
													return(PDQ_DateFromString(date(#output)));
											else;
													if: #this_pattern == 'uk';
															local: 'this' = (date(String_ReplaceRegexp(#output, -Find=(#regex_day #regex_delimeter #regex_month #regex_delimeter #regex_year), -Replace='\\2/\\1/\\3')));
															return(PDQ_DateFromSTring(date(#this)));
													/if;
											/if;
											loop_abort;
									else;
									
											local: 'this' = #munged_date;
											if: valid_date(#this);
													if: string(#this) >> '0000';
															local: 'munged_date' = #this;
															#munged_date = date(#munged_date);
															#munged_date = string(#munged_date);
															#munged_date = 
																(String_ReplaceRegExp:
																	#munged_date,
																	-Find='0000',
																	-Replace=((date)->Year(-Long)),
																	)
																;
															#this = #munged_date;
													/if;
													return(PDQ_DateFromSTring(date(#this)));
											else: valid_date(#this + '/2004');
													return(PDQ_DateFromSTring(date(#this + '/2004')));
											/if;
									/if;
							/iterate;
							
							//return('found something');

							local: 'munged_date' = #this;
							#munged_date = date(#munged_date);
							#munged_date = string(#munged_date);
							#munged_date = 
								(String_ReplaceRegExp:
									#munged_date,
									-Find='0000',
									-Replace=((date)->Year(-Long)),
									)
								;
							
							
							
							// we are going to have to munge it  :(
							
							
						
							
							// normalize whitespace
							#munged_date = 
								(String_ReplaceRegExp:
									#munged_date,
									-Find='(\s+)',
									-Replace=' ',
									)
								;
							
							
							// replace the month
							iterate: #some_months, local: 'a_month';
									#munged_date = 
										(String_ReplaceRegExp:
											#munged_date,
											-Find='(' #a_month ')',
											-Replace=' ',
											)
										;
							/iterate;
							
							
							
							// replace any hyphens with slashes
							#munged_date = 
								(String_ReplaceRegExp:
									#munged_date,
									-Find='(-+)',
									-Replace='/',
									)
								;
							
							if: valid_date(#munged_date);
									return((date(#munged_date))->Format('%Q %H:%M:%S'));
							else;
									return(false);
							/if;
					/if;
					
					
			/define_tag;
//	/If;



	
	/*
		PDQ_Valid_Date
		
		Returns (true|false)
		
		Checks to see whether a supplied value is a valid date, and, if supplied, the required format
		
		
		!!! FORMAT IS NOT IMPLEMENTED AS OF 10/2/04 6:52 PM  !!!
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Date');
			define_tag:'PDQ_Valid_Date', -Required='Input', -Optional='Format';
			
					// NOTE: -Format is not implemented yet
			
					// first we'll see if we have to match a certain format
/* 					if: (params) >> -Format; */
/* 							// yes, we do */
/* 							local:'a_format' = String(#Format); */
/* 							local: 'enforceFormat' = true; */
/* 							 */
/* 							// NOTE -- FORMAT IS NOT IMPLEMENTED YET, HENCE, THE OVERRIDE HERE: */
/* 							local: 'enforceFormat' = false; */
/* 					else; */
/* 							// no, any old format will do */
/* 							local: 'enforceFormat' = false; */
/* 					/if; */
					
					if: valid_date(PDQ_DateFromString(#Input));
							return(true);
					else;
							return(false);
					/if;
					
			/define_tag;
	/If;
	
	
	
	
	
	
	
	
	/*
		PDQ_Valid_MaxLength
		
		Returns (true|false)
		
		Checks to see whether a supplied value is longer than the supplied allowed value
	
		      maxLength: compares length of submitted value to maxLength
		          input: any -- casts to string before compare
		        returns: true | false
	*/
	$PDQ_ValidationKeys->insert('maxLength');
	$PDQ_ValidationTags->insert('maxLength'='PDQ_Valid_MaxLength');
	If: !(Lasso_TagExists: 'PDQ_Valid_MaxLength');
			define_tag:'PDQ_Valid_MaxLength', -Required='Input', -Required='Size';
					Local:'a_input' = String(#Input);
					Local:'a_size' = Integer(#Size);
					if: #a_input->Size <= #a_size;
							Return: true;
					else;
							Return: false;
					/if;
			/define_tag;
	/If;
	
	
	
	
	
	
	
	
	/*
		PDQ_Valid_MinLength
		
		Returns (true|false)
		
		Checks to see whether a supplied value is longer than the supplied allowed value
		
		       minValue: compares submitted value to minValue
		          input: integer | decimal | date | dateTime | time
		        returns: true | false
	*/
	$PDQ_ValidationKeys->insert('minLength');
	$PDQ_ValidationTags->insert('minLength'='PDQ_Valid_MinLength');
	If: !(Lasso_TagExists: 'PDQ_Valid_MinLength');
			define_tag:'PDQ_Valid_MinLength', -Required='Input', -Required='Size';
					Local:'a_input' = String(#Input);
					Local:'a_size' = Integer(#Size);
					if: #a_input->Size >= #a_size;
							Return: true;
					else;
							Return: false;
					/if;
			/define_tag;
	/If;
	
	
	
	
	
	
	
	
	/*
		PDQ_Valid_Numeric
		
		Returns (true|false)
		
		Checks to see whether a supplied value is numeric string
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Numeric');
			define_tag:'PDQ_Valid_Numeric', -Required='Input';
					Local:'a_input' = String(#Input);
					if: (params) >> -Strict;
							iterate: #a_input, local: 'a_char';
									if: (String_IsNumeric(#a_char) == false);
											return: false;
									/if;
							/iterate;
					else;
							iterate: #a_input, local: 'a_char';
									if: #a_char != ' ';
											if: (String_IsNumeric(#a_char) == false);
													return: false;
											/if;
									/if;
							/iterate;
					/if;
					Return: true;
			/define_tag;
	/If;





	/*
		PDQ_Valid_Integer
		
		Returns (true|false)
		
		Checks to see whether a supplied value is a valid integer
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Integer');
			define_tag:'PDQ_Valid_Integer', -Required='Input';
					Local:'a_input' = String(#Input);
					iterate: #a_input, local: 'a_char';
						if: (String_IsNumeric(#a_char) == false);
								return: false;
						/if;
					/iterate;
					#a_input = integer(#Input);
					
					Return(true);
			/define_tag;
	/If;






	/*
		PDQ_Valid_Decimal
		
		Returns (true|false)
		
		Checks to see whether a supplied value is a valid decimal
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Decimal');
			define_tag:'PDQ_Valid_Decimal', -Required='Input';
					Local:'a_input' = String(#Input);
					iterate: #a_input, local: 'a_char';
						if: #a_char != '.';
								if: (String_IsNumeric(#a_char) == false);
										return: false;
								/if;
						/if;
					/iterate;
					#a_input = decimal(#Input);
					
					Return(true);
			/define_tag;
	/If;






	/*
		PDQ_Valid_AlphaNumeric
		
		Returns (true|false)
		
		Checks to see whether a supplied value is alhpa-numeric string
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_AlphaNumeric');
			define_tag:'PDQ_Valid_AlphaNumeric', -Required='Input';
					Local:'a_input' = String(#Input);
					if: (params) >> -Strict;
							iterate: #a_input, local: 'a_char';
									if: #a_char->IsAlnum == false;
											return: false;
									/if;
							/iterate;
					else;
							iterate: #a_input, local: 'a_char';
									if: #a_char != ' ';
											if: #a_char->IsAlnum == false;
													return: false;
											/if;
									/if;
							/iterate;
					/if;
					Return: true;
			/define_tag;
	/If;


	/*
		PDQ_Valid_Alpha
		
		Returns (true|false)
		
		Checks to see whether a supplied value is alphabetic-only
	
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Alpha');
			define_tag:'PDQ_Valid_Alpha', -Required='Input';
					Local:'a_input' = String(#Input);
					if: (params) >> -Strict;
							iterate: #a_input, local: 'a_char';
									if: #a_char->IsAlpha == false;
											return: false;
									/if;
							/iterate;
					else;
							iterate: #a_input, local: 'a_char';
									if: #a_char != ' ';
											if: #a_char->IsAlpha == false;
													return: false;
											/if;
									/if;
							/iterate;
					/if;
					Return: true;
			/define_tag;
	/If;




	/*
		PDQ_Valid_MaxValue
		
		Returns (true|false)
		
		Checks to see whether a supplied value is longer than the supplied allowed value
		
		
		       maxValue: compares submitted value to maxValue, based on dataType
		          input: integer | decimal | date | dateTime | time
		        returns: true | false
	*/
	$PDQ_ValidationKeys->insert('maxValue');
	$PDQ_ValidationTags->insert('maxValue'='PDQ_Valid_MaxValue');
	If: !(Lasso_TagExists: 'PDQ_Valid_MaxValue');
			define_tag:'PDQ_Valid_MaxValue', -Required='Input', -Required='Max';
					// Max
					if: (String_IsNumeric(#Max));
							Local:'a_value' = integer(#Max);
					else: #Max->Isa: 'date';
							// max is a date
							Local:'a_value' = date(#Max);
					else: (PDQ_Valid_Date: #Max);
							// max is a date
							Local:'a_value' = date(#Max);
					else: #Max->Isa: 'string';
							// Max is a string
							if: (PDQ_Valid_Alpha: #Max, -Strict);
									// Max is not numeric
									return: 'Error - Max must be a valid date, decimal, or integer.';
							else: #Max >> '.';
									// convert to a decimal
									Local:'a_value' = decimal(#Max);
							else: (PDQ_Valid_Date: #Max);
									// convert to a date
									Local:'a_value' = date(#Max);
							else;
									Local:'a_value' = integer(#Max);
							/if;
					else: #Max->Isa: 'integer';
							Local:'a_value' = integer(#Max);
					else: #Max->Isa: 'decimal';
							Local:'a_value' = decimal(#Max);
					else;
							return: 'Error - Max must be a valid date, decimal, or integer.';
					/if;
					
					
					
					
					
					// Input
					if: (String_IsNumeric(#Input));
							Local:'a_input' = integer(#Input);
					else: boolean(PDQ_Valid_Date: #Input);
							Local:'a_input' = date(#Input);
					else: #Input->Isa: 'string';
							if: (PDQ_Valid_Alpha: #Input, -Strict);
									return(false);
							else: #Input >> '.';
									// convert to a decimal
									Local:'a_input' = decimal(#Input);
							else;
									Local:'a_input' = integer(#Input);
							/if;
					else: #Input->Isa: 'integer';
							Local:'a_input' = integer(#Input);
					else: #Input->Isa: 'decimal';
							Local:'a_input' = decimal(#Input);
					else;
							return: false;
					/if;
					
					
					if: #a_value->Isa: 'date' && #a_input->Isa: 'string';
							return(false);
					/if;
					
					if: #a_value->Isa: 'date' && #a_input->Isa: 'integer';
							return(false);
					/if;
					
					if: #a_input <= #a_value;
							Return: true;
					else;
							Return: false;
					/if;
			/define_tag;
	/If;


	/*]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	Valid_Phone
	
	Returns { true | false } depending upon whether the input is valid or not.
	
	 ^(\(?\d\d\d\)?)?[ -]?\d\d\d[ -]?\d\d\d\d$
	
	 ^(\(?\d\d\d\)?)?[ -]?\d\d\d[ -]?\d\d\d\d$ -- loose
	 ^(\(\d\d\d\) )?\d\d\d[ -]\d\d\d\d$ -- strict

	------------------------------------------------------------------ Chris Corwin ---->
	[*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Phone');
			define_tag:'PDQ_Valid_Phone', -Required='Input';
					Local:'a_number' = (String: #Input);
					Local: 'regex_Loose' = '^(\\(?\\d\\d\\d\\)?)?[ -]?\\d\\d\\d[ -]?\\d\\d\\d\\d$';
					Local: 'regex_Strict' = '^(\\(\\d\\d\\d\\) )?\\d\\d\\d[ -]\\d\\d\\d\\d$';
					if: (params) >> -Strict;
							Local: 'a_regex' = @#regex_strict;
					else;
							Local: 'a_regex' = @#regex_loose;
					/if;
					Return: (Boolean: (String_FindRegExp: #a_number, -Find=#a_regex)->Size);
			/define_tag;
	/If;






	/*
		PDQ_Valid_SSN
		
		Returns { true | false } depending upon whether the input is valid or not.
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_SSN');
			define_tag:'PDQ_Valid_SSN', -Required='Input';
					Local:'a_number' = (String: #Input);
					if: (params) >> -Strict;
							Return: (Boolean: (String_FindRegExp: #a_number, -Find='^\\d{3}\\-\\d{2}\\-\\d{4}$')->Size);
					else;
							Return: Boolean:((String_FindRegExp: #a_number, -Find='^\\d{3}[\\-]*\\d{2}[\\-]*\\d{4}$')->Size);
					/if;
			/define_tag;
	/If;





	/*
		PDQ_Valid_Email
		
		Returns { true | false } depending upon whether the input is valid or not.
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_Email');
			define_tag:'PDQ_Valid_Email', -Required='Input';
					local: 'emailPatterns' =
						Array(
							'.+@.+\\..+$',
							'^\\w.+@\\w.+\\.[a-z]+$',
							'^\\w[-_a-z~.]+@\\w[-_a-z~.]+\\.[a-z]{2}[a-z]*$',
							'^\\w[\\w\\d]+(\\.[\\w\\d]+)*@\\w[\\w\\d]+(\\.[\\w\\d]+)*\\.[a-z]{2,7}$',
							)
						;
					local:'a_input' = String(#Input);
					
					iterate: #emailPatterns, local: 'a_pattern';
							if: boolean((String_FindRegExp: #a_input, -Find=#a_pattern)->Size);
							else;
								return(false);
							/if;
							return(true);
					/iterate;
			/define_tag;
	/If;

	If: !(Lasso_TagExists: 'PDQ_Email_Obscure');
			define_tag:'PDQ_Email_Obscure', -Required='Input';
					local:'a_input' = String(#Input);
					#a_input = string_ReplaceRegExp(#a_input,-Find='\\@', -Replace='&nbsp;(at)&nbsp;');
					#a_input = string_ReplaceRegExp(#a_input,-Find='\\.', -Replace='&nbsp;(dot)&nbsp;');
					return(#a_input);
			/define_Tag;
	/if;



	/*
		PDQ_Valid_URL
		
		Returns { true | false } depending upon whether the input is valid or not.
	*/
	If: !(Lasso_TagExists: 'PDQ_Valid_URL');
			define_tag:'PDQ_Valid_URL', -Required='Input';
					local: 'patterns' =
						Array(
							'((http|ftp|https):\\/\\/)*(([\\w-]+\\.)+)([\\w-]+)(\\?*[\\w=\\&\\ ]*)',
							)
						;
					local:'a_input' = String(#Input);
					iterate: #patterns, local: 'a_pattern';
							if: boolean((String_FindRegExp: #a_input, -Find=#a_pattern)->Size);
							else;
								return(false);
							/if;
							return(true);
					/iterate;
			/define_tag;
	/If;













	define_tag:'lw_file_exists',-priority='replace',-required='filename';
		local:'out' = false;
		protect;
			#out = (boolean: ((include_raw: #filename)->size));
		/protect;
		return: #out;
	/define_tag;

	define_tag:'mhc_decrypt_blowfish',-priority='replace';
		local:'params' = params;
	
		local:'seedling' = null;
		if: #params->(find:'-seed')->size;
			#seedling = #params->(find:'-seed')->(get:1)->value;
			#params->(remove: (#params->(findposition:'-seed')->(get:1)));
		/if;
	
		local:'encrypted_string' = null;
		if: #params->size;
			if: #params->(get:1)->type == 'pair';
				#encrypted_string = #params->(get:1)->value;
			else;
				#encrypted_string = #params->(get:1);
			/if;
		/if;
	
		protect;
			handle_error;
				return: #encrypted_string;
			/handle_error;
			return: (decrypt_blowfish: -Seed=#seedling, #encrypted_string);
		/protect;
	
	/define_tag;



	/*]
	<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	"Define"
	
	I am similar to a "Var_Set", but have one very important
	difference: I check to see if the variable I am trying to
	set has already been defined, and I will not over-write it
	if it has.
	
	If, on the other hand, it has not been defined yet, I will
	then set it to the "Default".
	
	Example of use: 
	
	Define: -Name='myVar', -Default='myValue';
	------------------------------------------------------------->
	[*/
	If: !(Lasso_TagExists: 'Define');
			Define_Tag: 
				'Define',
				-Required='Name',
				-Required='Default'
				;
					If: !(Variable_Defined: #Name);
							Var: #Name = #Default;
					/If;
			/Define_Tag;
	/If;






	If: !(Lasso_TagExists: 'PDQ_Navbar');
			Define_Tag: 
				'PDQ_Navbar',
				-Required='thisNavBar',
				-Required='navbarStyleInfo'
				;
					Local: 'nextButtonState' = '';
					
					Local: 'output' = (String);
					
					
					
					Iterate: (Var: #thisNavBar), Local: 'a_thing';
							Local: 'button_' + (Loop_Count) + '_' + 'Label' = (#a_thing->(Find: 'Label'));
							Local: 'button_' + (Loop_Count) + '_' + 'Link' = (#a_thing->(Find: 'Path'));
							Local: 'button_' + (Loop_Count) + '_' + 'Title' = (#a_thing->(Find: 'Title'));
							Local: 'button_' + (Loop_Count) + '_' + 'Class' = (#a_thing->(Find: 'Class'));
							Local: 'button_' + (Loop_Count) + '_' + 'Disabled' = (#a_thing->(Find: 'disabled'));
					/Iterate;
					
					
					if(#thisNavBar->size);
					
					
					#output += '<ul ' #navbarStyleInfo ' >';
							Iterate: (Var: #thisNavBar), Local: 'a_thing';
									Local: 'thisLink' = (Local: 'button_' + (Loop_Count) + '_' + 'Link', -EncodeNone);
									/*]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
									Sets up and down state for a tags
									------------------------------------------------------------->
									[*/
									Loop: $thisLevel_Number;
											Local: 'pathsMatchFlag' = (Var: 'pathTo_Level_' + (Loop_Count))->(Contains: #thisLink);
											If: #pathsMatchFlag == true;
													Local: 'buttonState' = 'down';
											Else;
													Local: 'buttonState' = 'up';
											/If;
									/Loop;
									If: (Response_Path) != '/';
											If: #thisLink == '/';
													Local: 'buttonState' = 'up';
											/If;
									/If;
									If: #nextButtonState == 'down-helper';
											#buttonState = 'down-helper';
											#nextButtonState = '';
									/If;
									If: #buttonState == 'down';
											Local: 'nextButtonState' = 'down-helper';
									Else;
											Local: 'nextButtonState' = '';
									/If;
									#output += '<li class="' #buttonState '" >';
											If: (Variable_Defined: 'Navbar_LinkPrefix') == true;
													#output += $Navbar_LinkPrefix;
											/If;
											local: 'a_displayName' = (Local: 'button_' + (Loop_Count) + '_' + 'Label');
											If: #a_displayName >> '_';
													local: 'new_displayName' = (#a_displayName->(Split: '_'));
													#a_displayName = #new_displayName->(Join: '&nbsp;');
											/If;
											if(!((Local: 'button_' + (Loop_Count) + '_' + 'Disabled') == true));
													#output += '<a href="';
													#output += #thisLink;
													#output += '" ';
													#output += 'title="';
													#output += (Local: 'button_' + (Loop_Count) + '_' + 'Title');
													#output += '" ';
													#output += 'class="';
													#output += (Local: 'button_' + (Loop_Count) + '_' + 'Class');
													#output += '" ';
													#output += ' >';
											else;
													#output += '<span class="'(Local: 'button_' + (Loop_Count) + '_' + 'Class')'">';
													
											/if;
											#output += #a_displayName;
											if(!((Local: 'button_' + (Loop_Count) + '_' + 'Disabled') == true));
													#output += '</a>';
											else;
													#output += '</span>';
											/if;
											If: (Variable_Defined: 'Navbar_LinkSuffix') == true;
													#output += $Navbar_LinkSuffix;
											/If;
									#output += '</li>';
							/Iterate;
					#output += '</ul>';
					
					
					/if;
					
					Return: @#output;
			/Define_Tag;
	/If;

	If: !(Lasso_TagExists: 'Create_UID_20');
			Define_Tag: 
				'Create_UID_20'
				;
					Local: 'UID_Characters' = 'AaBb9CcDd8EeFf7GgHh6iJj5KkLm4NnoPp3QqRr2SsTt1UuVv9WwXx8YyZz';
					Local: 'UID_StringLength' = 20;
					Local: 'newUID' = (String);
					Loop: #UID_StringLength;
							Local: 
								'a_Character'
								 = 
								#UID_Characters->
									(Get: 
										(Math_Random: 
											-Min=1, 
											-Max=(#UID_Characters->Size)
											)
										)
								;
							#newUID += #a_Character;
					/Loop;
					Return: #newUID;
			/Define_Tag;
	/If;

/*
============================================================
"Phone_Format"
Author: Randy Phillips
Company: phillipsIT
Date: 11/29/2002
This tag places separators in phone numbers that are cast as
integers in the database.
Usage: (Phone_Format: -number=(field:'phone'), -separator='-')
˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
*/
	If: !(Lasso_TagExists: 'PDQ_Phone_Format');
			define_tag:'PDQ_Phone_Format';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				Select: #number->Size;
						Case: 10;
								Local:'string' = (string_insert:(string_insert:#number, -position=4, -text=@#separator), -position=8, -text=@#separator);
						Case: 7;
								Local:'string' = (string_insert: #number, -position=4, -text=@#separator);
						Case: 0;
								Local:'string' = '(unavailable)';
						Case;
								Local:'string' = (string_insert:(string_insert:#number, -position=3, -text=@#separator), -position=7, -text=@#separator);
				/Select;
				return(#string);
			/define_tag;
	/If;
	
	If: !(Lasso_TagExists: 'PDQ_Phone_FormDisplay');
			define_tag:'PDQ_Phone_FormDisplay';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				Select: #number->Size;
						Case: 10;
								Local:'string' = (string_insert:(string_insert:#number, -position=4, -text=@#separator), -position=8, -text=@#separator);
						Case: 7;
								Local:'string' = (string_insert: #number, -position=4, -text=@#separator);
						Case: 0;
								Local:'string' = '';
						Case;
								Local:'string' = (string_insert:(string_insert:#number, -position=3, -text=@#separator), -position=7, -text=@#separator);
				/Select;
				return(#string);
			/define_tag;
	/If;
	
	
	If: !(Lasso_TagExists: 'PDQ_SSN_Format');
			define_tag:'PDQ_SSN_Format';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				local: 'new_number' = string;
				iterate: #number, local: 'a_char';
						if: loop_count >= 6;
								#new_number += #a_char;
						else;
								#new_number += 'x';
						/if;
				/iterate;
				Select: #number->Size;
						Case: 9;
								Local:'string' = (string_insert:(string_insert:#new_number, -position=4, -text=@#separator), -position=7, -text=@#separator);
						Case;
								Local:'string' = #new_number;
				/Select;
				return(#string);
			/define_tag;
	/If;

	If: !(Lasso_TagExists: 'PDQ_SSN_FormatUnsafe');
			define_tag:'PDQ_SSN_FormatUnsafe';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				local: 'new_number' = string;
				iterate: #number, local: 'a_char';
						if: loop_count >= 6;
								#new_number += #a_char;
						else;
								#new_number += #a_char;
						/if;
				/iterate;
				Select: #number->Size;
						Case: 9;
								Local:'string' = (string_insert:(string_insert:#new_number, -position=4, -text=@#separator), -position=7, -text=@#separator);
						Case;
								Local:'string' = #new_number;
				/Select;
				return(#string);
			/define_tag;
	/If;
	
	If: !(Lasso_TagExists: 'PDQ_GetKeyValue');
			define_tag:'PDQ_GetKeyValue';
					return(Field: var($rewAction + '_UIDfieldName'));
			/define_tag;
	/if;



/*
============================================================
"Date_Relative"
˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
Returns "Today — 08:53:34 AM" if a date is since midnight
this morning, or as 
Usage: (Date_Relative: (Date));

˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
*/
	If: !(Lasso_TagExists: 'PDQ_Date_Relative');
			Define_Tag: 'PDQ_Date_Relative', -required='this';
					Local:
						'a_Date' = date(#this),
						'Now' = (Date),
						'Midnight' = date((date)->Format('%Y-%m-%d')),
						;
					if(#this == '');
							return('--');
					/if;
					Local: 'MidnightTonight' = #Midnight; 
					#MidnightTonight->(Add: (Duration: '24:00:00')); 
					Local: 'difference_DateToNow' = (#a_Date->(Difference: #Now, -Second));
					Local: 'difference_MidnightToNow' = (#Midnight->(Difference: #Now, -Second));
					Local: 'difference_NowToMidnightTonight' = (#Now->(Difference: #MidnightTonight, -Second));
					#difference_NowToMidnightTonight *= (-1);
					If: #difference_DateToNow <= (#difference_NowToMidnightTonight * 2 - #difference_MidnightToNow);
							If: (#a_Date->Year) > (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ', (' 
										+ (#a_Date->Year) 
										+ ') &#8212; ' 
										+ (Date_Format: #a_Date, -Format='%_h:%M %p')
										;
							Else;
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' &#8212; ' 
										+ (Date_Format: #a_Date, -Format='%_h:%M %p')
										;
							/If;
					Else: #difference_DateToNow <= #difference_NowToMidnightTonight;
							Local:'display' = 
								(
									'Tomorrow &#8212; ' 
									+ (Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= 0;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= #difference_MidnightToNow;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= (#difference_MidnightToNow + (24 * 60 * 60));
							Local:'display' = 
								(
									'Yesterday &#8212; ' 
									+ (Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: (#a_Date->Year) < (Date->Year);
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								+ ', (' 
								+ (#a_Date->Year) 
								+ ') &#8212; ' 
								+ (Date_Format: #a_Date, -Format='%_h:%M %p')
								;
					Else;
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								+ ' &#8212; ' 
								+ (Date_Format: #a_Date, -Format='%_h:%M %p')
								;
					/If;
					return(#display);
			/Define_Tag;
	/If;
	
	
	


/*
============================================================
"Date_Relative"
˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
Returns "Today — 08:53:34 AM" if a date is since midnight
this morning, or as 
Usage: (Date_Relative: (Date));

˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘˘
*/
	If: !(Lasso_TagExists: 'Date_Display');
			Define_Tag: 'Date_Display', -required='this';
					if: #this == '';
							return('--');
					/if;
					Local:
						'a_Date' = date(#this),
						;
					if: #a_Date == date('0000-00-00 00:00:00');
							return('--');
					else: #a_Date == date('0000-01-01 00:00:00');
							return('--');
					else;
							If: (#a_Date->Year) > (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ', ' 
										+ (#a_Date->Year) 
										+ '' 
										;
							else: (#a_Date->Year) < (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ', ' 
										+ (#a_Date->Year) 
										+ '' 
										;
							Else;
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										;
							/If;
							return(#display);
					/if;
					Local: 'MidnightTonight' = #Midnight; 
					#MidnightTonight->(Add: (Duration: '24:00:00')); 
					Local: 'difference_DateToNow' = (#a_Date->(Difference: #Now, -Second));
					Local: 'difference_MidnightToNow' = (#Midnight->(Difference: #Now, -Second));
					Local: 'difference_NowToMidnightTonight' = (#Now->(Difference: #MidnightTonight, -Second));
					#difference_NowToMidnightTonight *= (-1);
					
					
					If: #difference_DateToNow <= (#difference_NowToMidnightTonight * 2 - #difference_MidnightToNow);
							If: (#a_Date->Year) > (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' ' 
										+ (#a_Date->Year) 
										+ '' 
										;
							Else;
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' &#8212;' 
										;
							/If;
					Else: #difference_DateToNow <= #difference_NowToMidnightTonight;
							Local:'display' = 
								(
									'Tomorrow' 
								)
								;
					Else: #difference_DateToNow <= 0;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= #difference_MidnightToNow;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= (#difference_MidnightToNow * 2);
							Local:'display' = 
								(
									'Yesterday' + (#a_date)
								)
								;
					Else: (#a_Date->Year) < ((date)->Year);
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								+ ' (' 
								+ (#a_Date->Year) 
								+ ')' 
								;
					Else;
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								;
					/If;
					return(#display);
			/Define_Tag;
	/If;


	
	If: !(Lasso_TagExists: 'PDQ_SSN_PrepForDb');
			define_tag:'PDQ_SSN_PrepForDb';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
	/If;
	
	
	
	If: !(Lasso_TagExists: 'PDQ_Phone_PrepForDb');
			define_tag:'PDQ_Phone_PrepForDb';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
	/If;
	
	If: !(Lasso_TagExists: 'PDQ_ShortNote');
			define_tag:'PDQ_ShortNote', -required='Input';
					local: 'maxCharacters' = 50;
					local: 'a_string' = #Input;
					local: 'a_output' = string;
					if: #a_string->size <= #maxCharacters;
							#a_output += #a_string;
					else;
							//split on the fist period-space combo
							local: 'a_array' = #a_string->split('. ');
							#a_output = #a_array->First;
							if: #a_output->size < #maxCharacters;
									#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' $REW_Review '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
							else;
									//split on the fist period-space combo
									#a_output = string;
									local: 'a_array' = #a_string->split('. ');
									#a_output = #a_array->First;
									
									if: #a_output->size < #maxCharacters;
											#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' $REW_Review '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									else;
											#a_output = #a_output->substring(0, #maxCharacters) + @'&hellip;' + (encode_smart('&nbsp;<a href="' $REW_Review '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									/if;
							/if;
					/if;
					return(@(#a_output));
			/define_tag;
	/if;


	if: !(lasso_tagexists('Retrieve_HistoryEventTypes'));
			define_tag: 'Retrieve_HistoryEventTypes';
					local: 'gettypes' = '
						SELECT historyEventTypeUID, label FROM historyEventTypes
						WHERE historyEventTypeUID IS NOT NULL
						OR historyEventTypeUID != ""
						ORDER BY label ASC
						';
					local: 'result' = (array);
					inline:
						$connection_db,
						-sql=#gettypes,
						-table='historyEventTypes',
						-inlinename='historyEventTypes',
						-maxrecords='all'
						;
							rows;
									#result->Insert(Field('historyEventTypeUID')=Field('label'));
							/rows;
					/inline;
					return(#result);
			/define_Tag;
	/if;
	
	
	
	
	
	if: !(lasso_tagexists('FixLayout'));
			define_tag: 'FixLayout';
					Return(@('<p class="">(temporary layout issue being fixed here)</p>'));
			/define_tag;
	/if;
	


	define_tag:'lw_file_exists',-priority='replace',-required='filename';
		local:'out' = false;
		protect;
			#out = (boolean: ((include_raw: #filename)->size));
		/protect;
		return: #out;
	/define_tag;

	define_tag:'mhc_decrypt_blowfish',-priority='replace';
		local:'params' = params;
	
		local:'seedling' = null;
		if: #params->(find:'-seed')->size;
			#seedling = #params->(find:'-seed')->(get:1)->value;
			#params->(remove: (#params->(findposition:'-seed')->(get:1)));
		/if;
	
		local:'encrypted_string' = null;
		if: #params->size;
			if: #params->(get:1)->type == 'pair';
				#encrypted_string = #params->(get:1)->value;
			else;
				#encrypted_string = #params->(get:1);
			/if;
		/if;
	
		protect;
			handle_error;
				return: #encrypted_string;
			/handle_error;
			return: (decrypt_blowfish: -Seed=#seedling, #encrypted_string);
		/protect;
	
	/define_tag;


	if: !(lasso_tagexists('Retrieve_HistoryEventTypes'));
			define_tag: 'Retrieve_HistoryEventTypes';
					local: 'gettypes' = '
						SELECT historyEventTypeUID, label FROM historyEventTypes
						WHERE historyEventTypeUID IS NOT NULL
						OR historyEventTypeUID != ""
						ORDER BY label ASC
						';
					local: 'result' = (array);
					inline:
						$connection_db,
						-sql=#gettypes,
						-table='historyEventTypes',
						-inlinename='historyEventTypes',
						-maxrecords='all',
						;
							rows;
									#result->Insert(Field('historyEventTypeUID')=Field('label'));
							/rows;
					/inline;
					return(#result);
			/define_Tag;
	/if;
	
	
	
	
	
	if: !(lasso_tagexists('FixLayout'));
			define_tag: 'FixLayout';
					Return(@('<p class="">(temporary layout issue being fixed here)</p>'));
			/define_tag;
	/if;
	
	
	
	
	if( ! lasso_tagexists:('Lasso_Pimp'));
			define_tag:(
				'Lasso_Pimp'
				);
					Redirect_URL:('http://www.lassopimp.com');
			/define_tag;
	/if;


	
	
//	If: !(Lasso_TagExists: 'PDQ_ContentHeader');
			define_tag:'PDQ_ContentHeader', -priority='replace';
				local: 'outttishh' = string;
				#outttishh += '<div class="tab-left">';
				if($apparentUserTypeShortName == 'CompAdmin');
						#outttishh += '<div class="companyName">'(MHC_User_GetCompanyNameLong)'</div>';
				/if;
				#outttishh += '<h1>';

				if: response_filepath >> '/Monitor/Add/Patient/';
					local: 'get_patient' = 'SELECT * FROM ' + $siteDB + '.patients WHERE patientUID = "' ($monitoraddpatient_patient->(find:'patientUID')) '" LIMIT 1 ';
					Inline:
						$connection_db,
						-SQL=#get_patient;
						rows;
								var: 'patientUID' = (Field:'patientUID');
								var: 'patient_firstName' = (Field:'firstName');
								var: 'patient_lastName' = (Field:'lastName');
						/rows;					
					/inline;
					#outttishh += '<span class="detailName"><a href="/Patient/Info/"><span class="cap">' (String_LowerCase($patient_LastName))', '(String_LowerCase($patient_FirstName))'</span></a></span>';
				/if;
				
// 				if: variable_defined: 'patient_name';
// 						#outttishh += $patient_name;
// 				/if;

				(var('detailName') != '') ? #outttishh += ('<span class="detailName"><a href="' $rewAction_DetailPage_pathTo '">'  $detailName '</a></span>') | #outttishh += '';
				local('levelsSoFar'=string);
				iterate: $levels, local: 'this_level';
						if: #this_level != 'Home';
								#levelsSoFar += #this_level '/';
								if: loop_count == $levels->size;
										#outttishh += '<span class="';
										#outttishh += 'last';
								else;
										#outttishh += '<span class="';
										#outttishh += 'no' loop_count;
								/if;
								local: 'a_displayName' = #this_level;
								If: #a_displayName >> '_';
										local: 'new_displayName' = (#a_displayName->(Split: '_'));
										#a_displayName = #new_displayName->(Join: '&nbsp;');
								/If;
								if: loop_count == $levels->size;
										#outttishh += '">';
								else;
										#outttishh += '">';
								/if;
								if(loop_count == 2);
										inline:
											$connection_files,
											-nothing,
											;
												If: (File_Exists: '/_Assets/Images/title_' #this_level '.jpg') == true;
														#outttishh += '<img src="/_Assets/Images/title_' #this_level '.jpg" alt="" />';
														#outttishh +=  '&nbsp;';
												/if;
										/inline;
								/if;
								#outttishh += (#this_level != $thisLevel_Name ? '<a href="/' #levelsSoFar '">');
								#outttishh += #a_displayName;
								#outttishh += (#this_level != $thisLevel_Name ?'</a>');
								#outttishh +=  (loop_count != $levels->size ? '\r&gt;');
								#outttishh += '</span>\r\t\t';
								
						/if;
				/iterate;
				#outttishh += (  '</h1></div>');
				return(#outttishh);
			/define_tag;
//	/If;
	
	If: !(Lasso_TagExists: 'PDQ_SSN_PrepForDb');
			define_tag:'PDQ_SSN_PrepForDb';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
	/If;
	
	
	If: !(Lasso_TagExists: 'PDQ_Phone_PrepForDb');
			define_tag:'PDQ_Phone_PrepForDb';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
	/If;

	If: !(Lasso_TagExists: 'PDQ_Phone_FormDisplay');
			define_tag:'PDQ_Phone_FormDisplay';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				Select: #number->Size;
						Case: 10;
								Local:'string' = (string_insert:(string_insert:#number, -position=4, -text=@#separator), -position=8, -text=@#separator);
						Case: 7;
								Local:'string' = (string_insert: #number, -position=4, -text=@#separator);
						Case: 0;
								Local:'string' = '';
						Case;
								Local:'string' = (string_insert:(string_insert:#number, -position=3, -text=@#separator), -position=7, -text=@#separator);
				/Select;
				return(#string);
			/define_tag;
	/If;


	
	namespace_using('PDQ_');

			define_tag(
				'Phone', 
				-namespace='Valid_',
				-priority='replace',
				-description='Returns (true|false) depending upon whether the input is valid or not. Has an optional -Strict parameter.',
				-Required='Input'
				);
					fail_if(
						!params->size,
						-1,
						'[Valid_Phone] requires a requires at least one parameter.'
					);
					
					local(
						'a_number' = string(#Input),
						'regex_Loose' = '^(\\(?\\d\\d\\d\\)?)?[ -]?\\d\\d\\d[ -]?\\d\\d\\d\\d$',
						'regex_Strict' = '^(\\(\\d\\d\\d\\) )?\\d\\d\\d[ -]\\d\\d\\d\\d$'
						);
					if: (params) >> -Strict;
							Local: 'a_regex' = @#regex_strict;
					else;
							Local: 'a_regex' = @#regex_loose;
					/if;
					return(boolean(string_FindRegExp( #a_number, -Find=#a_regex)->size));
			/define_tag;
			
			
			define_tag(
				'SSN', 
				-namespace='Valid_',
				-priority='replace',
				-description='Returns (true|false) depending upon whether the input is valid or not. Has an optional -Strict parameter.',
				-Required='Input'
				);
					fail_if(
						!params->size,
						-1,
						'[Valid_SSN] requires a requires at least one parameter.'
					);
					
					local(
						'a_number' = string(#Input),
						'regex_Loose' = '^\\d{3}[\\-]*\\d{2}[\\-]*\\d{4}$',
						'regex_Strict' = '^\\d{3}\\-\\d{2}\\-\\d{4}$'
						);
					if: (params) >> -Strict;
							Local: 'a_regex' = @#regex_strict;
					else;
							Local: 'a_regex' = @#regex_loose;
					/if;
					return(boolean(string_FindRegExp( #a_number, -Find=#a_regex)->size));
			/define_tag;
			
			
			
			define_tag(
				'SSN',
				-namespace='PrepForDb_',
				-priority='replace',
				-description='Strips delimeters from a alphanumeric string, such as a SSN.'
				);
				local('number' = (params)->get(1));
				local('number' = string_ReplaceRegExp(#number,-Find='([^\\w\\d]+)',-Replace=''));
				return(#number);
			/define_tag;
			
			
			define_tag(
				'Phone',
				-namespace='PrepForDb_',
				-priority='replace',
				-description='Strips delimeters from a alphanumeric string, such as a phone number.'
				);
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				return(#number);
			/define_tag;
			
	
			define_tag:'PDQ_SSN_Format';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				local: 'new_number' = string;
				iterate: #number, local: 'a_char';
						if: loop_count >= 6;
								#new_number += #a_char;
						else;
								#new_number += 'x';
						/if;
				/iterate;
				Select: #number->Size;
						Case: 9;
								Local:'string' = (string_insert:(string_insert:#new_number, -position=4, -text=@#separator), -position=7, -text=@#separator);
						Case;
								Local:'string' = #new_number;
				/Select;
				return(#string);
			/define_tag;
			
			
			define_tag:'PDQ_SSN_FormatUnsafe';
				local: 'separator' = '-';
				Local:'number' = (params)->Get(1);
				local: 'number' = (String_ReplaceRegExp:#number,-Find='([^\\w\\d]+)',-Replace='');
				local: 'new_number' = string;
				iterate: #number, local: 'a_char';
						if: loop_count >= 6;
								#new_number += #a_char;
						else;
								#new_number += #a_char;
						/if;
				/iterate;
				Select: #number->Size;
						Case: 9;
								Local:'string' = (string_insert:(string_insert:#new_number, -position=4, -text=@#separator), -position=7, -text=@#separator);
						Case;
								Local:'string' = #new_number;
				/Select;
				return(#string);
			/define_tag;
			
	/namespace_using;
	
	
	
	define_tag(
		'pathfromroot',
		-namespace='file_',
		-priority='replace',
		-description='Converts a relative path to a root path.'
	);
		fail_if(
			!params->size || !params->first->isa('string'),
			-1,
			'[file_pathfromroot] requires a file path as a parameter.'
		);
		
		local('in' = params->first);
		
		if(#in->beginswith('/'));
			return(#in);
		else(#in->beginswith('../'));
			local('steps' = #in->split('../')->size - 1);
			local('out' = '/');
			
			iterate(response_path->split('/'), local('i'));
				loop_count > 1 ? #out += #i + '/';
				loop_count == #steps ? loop_abort;
			/iterate;
			
			#out += #in;
			return(#in);
		else;
			return(response_path + #in);
		/if;
	/define_tag;

	if(!(lasso_tagExists('PDQ_ShortNote')));
			define_tag(
				'once',
				-namespace='include_',
				-priority='replace',
				-description='Includes the specified file only if it has not already been included.'
			);
				fail_if(
					!params->size || !params->first->isa('string'),
					-1,
					'[include_once] requires a file path as a parameter.'
				);
				
				local('path') = file_pathfromroot(params->first);		
				!var_defined('included_files') ? var('included_files' = set);		
				
				if($included_files !>> #path);
					$included_files->insert(#path);
					return(include(#path));
				/if;		
			/define_tag;
	/if;

	If: !(Lasso_TagExists: 'PDQ_ShortNote');
			define_tag:'PDQ_ShortNote', -required='Input';
					local: 'maxCharacters' = 50;
					local: 'a_string' = #Input;
					local: 'a_output' = string;
					if: #a_string->size <= #maxCharacters;
							#a_output += #a_string;
					else;
							//split on the fist period-space combo
							local: 'a_array' = #a_string->split('. ');
							#a_output = #a_array->First;
							if: #a_output->size < #maxCharacters;
									#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
							else;
									//split on the fist period-space combo
									#a_output = string;
									local: 'a_array' = #a_string->split('. ');
									#a_output = #a_array->First;
									
									if: #a_output->size < #maxCharacters;
											#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									else;
											#a_output = #a_output->substring(0, #maxCharacters) + @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									/if;
							/if;
					/if;
					return(@(#a_output));
			/define_tag;
	/if;


	If: !(Lasso_TagExists: 'MHC_Date');
			Define_Tag: 'MHC_Date', -required='this';
					if: #this == '';
							return('no date specified');
					/if;
					Local:
						'a_Date' = date(#this),
						'Now' = (Date),
						'Midnight' = date((date)->Format('%Y-%m-%d')),
						;
					if: #a_Date == date('0000-00-00 00:00:00');
							return('no date specifiied');
					else: #a_Date == date('0000-01-01 00:00:00');
							return('no date specifiied');
					else;
							// return(#a_date);
					/if;
					Local: 'MidnightTonight' = #Midnight; 
					#MidnightTonight->(Add: (Duration: '24:00:00')); 
					Local: 'difference_DateToNow' = (#a_Date->(Difference: #Now, -Second));
					Local: 'difference_MidnightToNow' = (#Midnight->(Difference: #Now, -Second));
					Local: 'difference_NowToMidnightTonight' = (#Now->(Difference: #MidnightTonight, -Second));
					#difference_NowToMidnightTonight *= (-1);
					
					
					If: #difference_DateToNow <= (#difference_NowToMidnightTonight * 2 - #difference_MidnightToNow);
							If: (#a_Date->Year) > (Date->Year);
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' (' 
										+ (#a_Date->Year) 
										+ ')' 
										;
							Else;
									Local: 'display' = 
										(#a_Date->DayOfWeek: -Short) 
										+ ', ' 
										+ (#a_Date->Month: -Short) 
										+ ' ' 
										+ (#a_Date->Day) 
										+ ' &#8212;' 
										;
							/If;
					Else: #difference_DateToNow <= #difference_NowToMidnightTonight;
							Local:'display' = 
								(
									'Tomorrow' 
								)
								;
					Else: #difference_DateToNow <= 0;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= #difference_MidnightToNow;
							Local:'display' = 
								(
									(Date_Format: #a_Date, -Format='%_h:%M %p') 
								)
								;
					Else: #difference_DateToNow <= (#difference_MidnightToNow * 2);
							Local:'display' = 
								(
									'Yesterday' + (#a_date)
								)
								;
					Else: (#a_Date->Year) < ((date)->Year);
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								+ ' (' 
								+ (#a_Date->Year) 
								+ ')' 
								;
					Else;
							Local: 'display' = 
								(#a_Date->DayOfWeek: -Short) 
								+ ', ' 
								+ (#a_Date->Month: -Short) 
								+ ' ' 
								+ (#a_Date->Day) 
								;
					/If;
					return(#display);
			/Define_Tag;
	/If;


	If: !(Lasso_TagExists: 'PDQ_ExternalLink');
			define_tag:'PDQ_ExternalLink', -Required='Input';
					local:'a_input' = String(#Input);
					
					if(#a_input->size > 7);
							if(#a_input->beginswith('http://') || #a_input->beginswith('https://'));
							else;
									#a_input = 'http://' + #a_input;
							/if;
							if(PDQ_Valid_URL(#a_input));
									#a_input = '<a href="' + #a_input +'" class="offsite" target="_blank">' + 'link</a>' ;
									return(#a_input);
							else;
									return(#a_input);
							/if;
					else;
							return('--');
					/if;
			/define_Tag;
	/if;


	If: !(Lasso_TagExists: 'Summit_CoDisplay');
			define_tag:'Summit_CoDisplay';
					return(params);
					local:'a_input' = params->first;
					local:'a_URL' = params->second;
					if(#a_URL != '');
							if(#a_URL->beginswith('http://') || #a_URL->beginswith('https://'));
							else;
									#a_URL = 'http://' + #a_URL;
							/if;
					/if;
					if(PDQ_Valid_URL(#a_URL));
							#a_input = '<a href="' + #a_URL +'" class="offsite" target="_blank">' + #a_input + '</a>' ;
							return(#a_input);
					else;
							return(#a_input);
					/if;
			/define_Tag;
	/if;


	if(!Lasso_TagExists('PDQ_Tempo'));
		define_tag('PDQ_Tempo', 
			-required='param');
			return(date(#param)->format('%Y'));
			/* 					return(#param); */
		/define_tag;
	/if;
	if(!Lasso_TagExists('PDQ_GetKeyValue'));
		define_tag('PDQ_GetKeyValue');
			return(Field(var($rewAction + '_UIDfieldName')));
		/define_tag;
	/if;
	
	
	if(!Lasso_TagExists('Summit_PhotoSmall_FromUserUID'));
		define_tag('Summit_PhotoSmall_FromUserUID', -required='input');
			inline($connection_files);
					if(file_exists('/Summit/_Images/' + #input '/small.jpg'));
							return('<img src="/Summit/_Images/' + #input '/small.jpg">');
					/if;
			/inline;
		/define_tag;
	/if;
	
	if(!Lasso_TagExists('Summit_PhotoMedium_FromUserUID'));
		define_tag('Summit_PhotoMedium_FromUserUID', -required='input');
			inline($connection_files);
					if(file_exists('/Summit/_Images/' + #input '/medium.jpg'));
							return('<img src="/Summit/_Images/' + #input '/medium.jpg">');
					/if;
			/inline;
		/define_tag;
	/if;


	If: !(Lasso_TagExists: 'PDQ_ShortNote');
			define_tag:'PDQ_ShortNote', -required='Input';
					local: 'maxCharacters' = 50;
					local: 'a_string' = #Input;
					local: 'a_output' = string;
					if: #a_string->size <= #maxCharacters;
							#a_output += #a_string;
					else;
							//split on the fist period-space combo
							local: 'a_array' = #a_string->split('. ');
							#a_output = #a_array->First;
							if: #a_output->size < #maxCharacters;
									#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
							else;
									//split on the fist period-space combo
									#a_output = string;
									local: 'a_array' = #a_string->split('. ');
									#a_output = #a_array->First;
									
									if: #a_output->size < #maxCharacters;
											#a_output += @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									else;
											#a_output = #a_output->substring(0, #maxCharacters) + @'&hellip;' + (encode_smart('&nbsp;<a href="' (Var: ($rewAction + '_EditPage')) '?and=' field(Var: ($rewAction + '_UidFieldName')) '">More</a>'));
									/if;
							/if;
					/if;
					return(@(#a_output));
			/define_tag;
	/if;
	

]